XuanShu API

Chat Completions API

OpenAI-compatible Chat Completions requests and streaming responses.

Last verified:

Connection and authentication

Unified OpenAI-compatible Base URL: https://www.xuanshuapi.com/v1

OpenAI-compatible APIs use Authorization: Bearer <YOUR_API_KEY>; Claude Messages also accepts x-api-key: <YOUR_API_KEY>; Gemini v1beta uses x-goog-api-key: <YOUR_API_KEY>.

Chat Completions API

POST /v1/chat/completions accepts compatible message payloads; stream=true uses SSE.

Not every model supports the same parameters; query Models first.

Request and call

Chat Completions uses a messages array, supports temperature, and enables SSE with stream.

curl https://www.xuanshuapi.com/v1/chat/completions \
  -H "Authorization: Bearer <YOUR_API_KEY>" -H "content-type: application/json" \
  -d '{"model":"<MODEL_FROM_MODELS>","messages":[{"role":"user","content":"Reply with OK"}],"temperature":0,"stream":false}'

Response and streaming behavior

Non-streaming text is in choices[0].message.content; streaming deltas are in choices[0].delta.content.

HTTP 200
{"object":"chat.completion","choices":[{"message":{"role":"assistant","content":"OK"},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":1}}

Key parameters

ParameterDescription
modelChoose from /v1/models.
messagesConversation roles and content.
temperatureUse only when supported by the model.
streamEnables SSE.

Typical failures

For 400 verify model parameter support; for 401/403 inspect credentials and model access; use bounded backoff for 429/5xx.

HTTP 400  # model does not support a parameter
HTTP 401/403  # key or model access
HTTP 429/5xx  # bounded retry candidate

Next steps

Available models, multipliers, quotas, and some advanced capabilities depend on the current key and console configuration.