Create a model response for a chat conversation. Request and response shapes follow OpenAI Chat Completions. Unlisted top-level fields are passed through when safe.

POST https://ai.win10030.com/v1/chat/completions

Authentication

Authorization: Bearer YOUR_API_KEY — required.

Recommended headers

HeaderDescription
Content-Typeapplication/json
Acceptapplication/json, or text/event-stream when stream: true
x-trace-idOptional correlation id (max 256 chars)
x-user-idOptional end-user id in your system
x-agent-nameOptional agent name (recorded in usage)

Request body

FieldRequiredDescription
modelyesCatalog id from GET /models
messagesyesArray, min length 1
streamnotrue → SSE (chat.completion.chunk)
max_tokensnoMax output tokens
temperature, top_pnoSampling
stopnoString or string array
frequency_penalty, presence_penaltynoOpenAI-compatible
seednoInteger seed when upstream supports
toolsnoUp to 64 function tools
tool_choicenonone / auto / required or named function
pdf_preprocessnoGateway PDF extension (below)
extra_bodynoJSON object merged into upstream (OpenAI-compatible routes)
stream_optionsnoGateway always enables include_usage on streams

Limit: JSON body up to 32 MB.

messages[]

roleNotes
system, user, assistant, developerStandard
toolNon-empty tool_call_id required
assistantMay include tool_calls; content may be null when only tools

content may be a string, null (treated as empty), or an array of parts for multimodal user messages.

User content parts

typeDescription
textPlain text
image_url{ "url": "...", "detail": "auto" }
input_audioAudio input (OpenAI wire)
fileFile input with nested file object: { "file": { "file_data": "...", "filename": "..." } }

pdf_preprocess (gateway)

{ "engine": "native" }
engineBehavior
nativeDefault — forward unchanged
ocrOCR then send upstream
markdownExtract as Markdown

Optional: max_pages (≤ 50), merge_pages.

Non-streaming example

curl -sS "https://ai.win10030.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [{"role": "user", "content": "Summarize edge gateways in one sentence."}]
  }'

Streaming

Set "stream": true and Accept: text/event-stream. See Streaming and Streaming quickstart.

Tools example

curl -sS "https://ai.win10030.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [{"role": "user", "content": "What is the weather in Paris?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get weather for a city",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

After tool_calls, append the assistant message with calls, then role: "tool" results, and call again.

Multimodal (files)

Send files in user content arrays via file parts with nested file object:

file fieldDescription
file_dataInline base64 data, supports data:<mime>;base64,... format
filenameFile name for MIME type inference (e.g. spec.pdf)

Inline file example

curl -sS "https://ai.win10030.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"model\": \"YOUR_MODEL_ID\",
    \"messages\": [{
      \"role\": \"user\",
      \"content\": [
        { \"type\": \"text\", \"text\": \"List key requirements\" },
        { \"type\": \"file\", \"file\": { \"filename\": \"spec.pdf\", \"file_data\": \"data:application/pdf;base64,$(base64 spec.pdf | tr -d '\n')\" } }
      ]
    }]
  }"

Image examples

image_url (OpenAI-compatible):

{ "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg" } }

Or file with inline base64:

{ "type": "file", "file": { "filename": "photo.jpg", "file_data": "data:image/jpeg;base64,..." } }

See Files and context.

Response (non-streaming)

OpenAI-shaped chat.completion with choices[].message, usage, and id.

Errors

{
  "error": {
    "message": "...",
    "type": "invalid_request_error",
    "param": "messages[0].content",
    "code": null
  }
}
StatusTypical cause
400Validation (messages, parts, size)
401Invalid or expired API key
403Model denied, balance, IP, upstream keys
429Rate limit
502/503Upstream failure

See Errors · OpenAI differences.