POST
/
v1
/
chat
/
completions
OpenAI - chat completion
curl --request POST \
  --url https://coder.api.visioncoder.cn/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-5.4",
  "messages": [
    {
      "role": "user",
      "content": "Hello",
      "name": "<string>",
      "tool_call_id": "<string>"
    }
  ],
  "temperature": 0.7,
  "top_p": 1,
  "n": 1,
  "max_tokens": 4096,
  "max_completion_tokens": 123,
  "stream": false,
  "stop": "<unknown>",
  "presence_penalty": 0,
  "frequency_penalty": 0,
  "seed": 123,
  "response_format": {},
  "tools": [
    {}
  ],
  "tool_choice": "<unknown>",
  "user": "<string>"
}
'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1730000000,
  "model": "gpt-5.4",
  "system_fingerprint": "<string>",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you?",
        "tool_calls": [
          {}
        ]
      },
      "logprobs": {},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 28,
    "total_tokens": 40
  }
}

调用示例

curl https://coder.api.visioncoder.cn/v1/chat/completions \
  -H "Authorization: Bearer $VISIONCODER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "messages": [
      {"role": "user", "content": "Hello"}
    ],
    "stream": false
  }'

响应示例

{
  "id": "chatcmpl-9aB2k4xQwR7vL8mN",
  "object": "chat.completion",
  "created": 1779438767,
  "model": "gpt-5.4",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hi! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 8,
    "completion_tokens": 9,
    "total_tokens": 17
  }
}
流式响应("stream": true)以 SSE 返回,每个 chunk 遵循 OpenAI delta 格式:
data: {"id":"chatcmpl-9aB2k4xQwR7vL8mN","object":"chat.completion.chunk","created":1779438767,"model":"gpt-5.4","choices":[{"index":0,"delta":{"role":"assistant","content":"Hi"},"finish_reason":null}]}

data: {"id":"chatcmpl-9aB2k4xQwR7vL8mN","object":"chat.completion.chunk","created":1779438767,"model":"gpt-5.4","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}

data: {"id":"chatcmpl-9aB2k4xQwR7vL8mN","object":"chat.completion.chunk","created":1779438767,"model":"gpt-5.4","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

加群 & 客服

AI 技术交流群二维码
专属客服二维码

Authorizations

Authorization
string
header
required

Use the API key created at https://coder.visioncoder.cn/key as the Bearer token. Anthropic clients can pass the same key via the x-api-key header.

Body

application/json

OpenAI Chat Completions request body. The platform forwards it upstream as-is; fields follow the official OpenAI protocol.

model
string
required

Model ID. Accepts any chat-capable model returned by GET /v1/models — e.g. OpenAI gpt-5.4 / gpt-5.5, Anthropic claude-sonnet-4-6 / claude-opus-4-7, or open-source deepseek-v4-pro / qwen3.6-35b-a3b / kimi-k2.6 / glm-5.1 / minimax-m2.7.

Example:

"gpt-5.4"

messages
object[]
required

Conversation message list

temperature
number<float>
default:1
Required range: 0 <= x <= 2
Example:

0.7

top_p
number<float>
default:1
Required range: 0 <= x <= 1
n
integer
default:1

Number of candidate completions to generate

max_tokens
integer

Maximum output tokens

Example:

4096

max_completion_tokens
integer

Newer field, equivalent to max_tokens

stream
boolean
default:false

Whether to stream the response via SSE

stop
any

Stop sequence(s); string or array of strings

presence_penalty
number<float>
Required range: -2 <= x <= 2
frequency_penalty
number<float>
Required range: -2 <= x <= 2
seed
integer
response_format
object
tools
object[]

Function-calling tool definitions

tool_choice
any

Tool choice strategy; string or object

user
string

End-user identifier

Response

200 - application/json

A successful response.

OpenAI Chat Completions response body. Fields follow the official OpenAI protocol.

id
string
Example:

"chatcmpl-abc123"

object
string
Example:

"chat.completion"

created
integer
Example:

1730000000

model
string
Example:

"gpt-5.4"

system_fingerprint
string
choices
object[]
usage
object