Session Playground

POST /pg/chat/completions

Native access token · POST /pg/chat/completions

使用原生登录 access_token 直接扣减本人钱包调用 OpenAI 兼容 Chat JSON/SSE,不创建推理 Key,也不套用 facade 的 {data:...} 外壳。支持稳定 Idempotency-Key 持久化意图与断线恢复,禁用网关内部换渠道重试。

POST/pg/chat/completions

Authorizations

Authorizationstringrequired

Use a native login access_token (required access: Native access token) with owner isolation and trusted browser Origin; generation writes use wallet billing while reads do not precharge; inference API Keys (sk-…) and PATs (nap_…) are rejected.

Authorization: Bearer $ONEASTER_ACCESS_TOKEN

Parameters

Idempotency-Keystring

header · 每次新发起的 /pg 生成提交建议由前端生成并持久化稳定的 1–100 位无空格可打印 ASCII 标识(推荐 UUID),断线重试保持原标识与原请求字节。同账号跨所有 /pg POST 协议共用一个命名空间;省略时后端兼容生成并通过 X-OneAster-Intent-ID 返回,但若响应头丢失将无法按意图恢复。

Body · application/json

modelstringrequired

模型 ID

messagesarrayrequired

对话消息列表

temperaturenumber

采样温度

top_pnumber

核采样参数

ninteger

生成数量

streamboolean

是否流式响应

stream_optionsobject
stoponeOf

停止序列

max_tokensinteger

最大生成 Token 数

max_completion_tokensinteger

最大补全 Token 数

presence_penaltynumber
frequency_penaltynumber
logit_biasobject
userstring
toolsarray
tool_choiceoneOf
response_formatobject
seedinteger
reasoning_effortstring

推理强度 (用于支持推理的模型)

modalitiesarray
audioobject
JSON Schema
{
  "type": "object",
  "required": [
    "model",
    "messages"
  ],
  "properties": {
    "model": {
      "type": "string",
      "description": "模型 ID",
      "example": "gpt-4"
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "user",
              "assistant",
              "tool",
              "developer"
            ],
            "description": "消息角色"
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "text",
                        "image_url",
                        "input_audio",
                        "file",
                        "video_url"
                      ]
                    },
                    "text": {
                      "type": "string"
                    },
                    "image_url": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "description": "图片 URL 或 base64"
                        },
                        "detail": {
                          "type": "string",
                          "enum": [
                            "low",
                            "high",
                            "auto"
                          ]
                        }
                      }
                    },
                    "input_audio": {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "string",
                          "description": "Base64 编码的音频数据"
                        },
                        "format": {
                          "type": "string",
                          "enum": [
                            "wav",
                            "mp3"
                          ]
                        }
                      }
                    },
                    "file": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "type": "string"
                        },
                        "file_data": {
                          "type": "string"
                        },
                        "file_id": {
                          "type": "string"
                        }
                      }
                    },
                    "video_url": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            ],
            "description": "消息内容"
          },
          "name": {
            "type": "string",
            "description": "发送者名称"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "example": "function"
                },
                "function": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "arguments": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "tool_call_id": {
            "type": "string",
            "description": "工具调用 ID(用于 tool 角色消息)"
          },
          "reasoning_content": {
            "type": "string",
            "description": "推理内容"
          }
        }
      },
      "description": "对话消息列表"
    },
    "temperature": {
      "type": "number",
      "minimum": 0,
      "maximum": 2,
      "default": 1,
      "description": "采样温度"
    },
    "top_p": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "default": 1,
      "description": "核采样参数"
    },
    "n": {
      "type": "integer",
      "minimum": 1,
      "default": 1,
      "description": "生成数量"
    },
    "stream": {
      "type": "boolean",
      "default": false,
      "description": "是否流式响应"
    },
    "stream_options": {
      "type": "object",
      "properties": {
        "include_usage": {
          "type": "boolean"
        }
      }
    },
    "stop": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      ],
      "description": "停止序列"
    },
    "max_tokens": {
      "type": "integer",
      "description": "最大生成 Token 数"
    },
    "max_completion_tokens": {
      "type": "integer",
      "description": "最大补全 Token 数"
    },
    "presence_penalty": {
      "type": "number",
      "minimum": -2,
      "maximum": 2,
      "default": 0
    },
    "frequency_penalty": {
      "type": "number",
      "minimum": -2,
      "maximum": 2,
      "default": 0
    },
    "logit_bias": {
      "type": "object",
      "additionalProperties": {
        "type": "number"
      },
      "properties": {}
    },
    "user": {
      "type": "string"
    },
    "tools": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "example": "function"
          },
          "function": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "parameters": {
                "type": "object",
                "description": "JSON Schema 格式的参数定义",
                "properties": {}
              }
            }
          }
        }
      }
    },
    "tool_choice": {
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "none",
            "auto",
            "required"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string"
            },
            "function": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                }
              }
            }
          }
        }
      ]
    },
    "response_format": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "text",
            "json_object",
            "json_schema"
          ]
        },
        "json_schema": {
          "type": "object",
          "description": "JSON Schema 定义",
          "properties": {}
        }
      }
    },
    "seed": {
      "type": "integer"
    },
    "reasoning_effort": {
      "type": "string",
      "enum": [
        "low",
        "medium",
        "high"
      ],
      "description": "推理强度 (用于支持推理的模型)"
    },
    "modalities": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "text",
          "audio"
        ]
      }
    },
    "audio": {
      "type": "object",
      "properties": {
        "voice": {
          "type": "string"
        },
        "format": {
          "type": "string"
        }
      }
    }
  }
}