API Documentation
XHuoAPI speaks the OpenAI Chat Completions format, plus the Anthropic Messages format for Claude models. One key covers 70+ models.
Interactive API reference (try requests online) →
Base URL
https://api.xhuoapi.ai
Quick Start
- Sign up at the console
- Create an API key in the console
- Point your Base URL to
https://api.xhuoapi.ai - Start making requests
Supported endpoints
Every row below was tested with a real API key. Endpoints not listed here are not guaranteed to work, even if the path responds.
Last verified: · Base URL https://api.xhuoapi.ai
| Endpoint | Format | Description |
|---|---|---|
POST /v1/chat/completions |
OpenAI | All chat models. stream, tools and response_format were verified on deepseek-v3.2; support on other models depends on the vendor. |
POST /v1/messages |
Anthropic | Claude models (tested with claude-sonnet-4-6). Authenticate with either x-api-key or Authorization: Bearer. |
GET /v1/models |
OpenAI | Lists every model available to your key. |
POST /v1/embeddings |
OpenAI | text-embedding-3-small returns 1536-dimension vectors. The catalogue also lists text-embedding-3-large and text-embedding-ada-002 (not separately tested). |
For the OpenAI SDK set base_url to https://api.xhuoapi.ai/v1. For the Anthropic SDK use https://api.xhuoapi.ai; the SDK appends /v1/messages itself.
Authentication
Every request must include your API key in the HTTP header:
Authorization: Bearer YOUR_API_KEY
⚠️ Security notice: never expose your API key in client-side code. Proxy requests through your own backend instead.
Chat Completions
Create a chat completion. Works with every model on the platform.
/v1/chat/completions
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | ✅ | Model ID, e.g. gpt-4o |
messages |
array | ✅ | List of conversation messages |
temperature |
number | ❌ | Sampling temperature (0-2), defaults to 1 |
max_tokens |
integer | ❌ | Maximum number of tokens to generate |
stream |
boolean | ❌ | Stream partial results, defaults to false |
Example Request
curl https://api.xhuoapi.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello, introduce yourself"
}
],
"temperature": 0.7
}'
Example Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I am an AI assistant..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 20,
"total_tokens": 32
}
}
List Models
Retrieve the list of every model available to your key.
/v1/models
Example Request
curl https://api.xhuoapi.ai/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
Commonly used models (tested)
These models answered normally in the latest test run (date under "Supported endpoints"). The full list and per-tier prices are on the pricing page.
deepseek-v3.2
DeepSeek
qwen3.8-max
Alibaba · Qwen
glm-5.3
Zhipu · GLM
kimi-k3
Moonshot · Kimi
claude-sonnet-4-6
Anthropic
gpt-4.1-mini
OpenAI
gemini-2.5-flash
Streaming
Set stream: true to receive tokens as they are generated.
Example Request
curl https://api.xhuoapi.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Tell me a joke"}],
"stream": true
}'
Response Format
Streamed responses use Server-Sent Events (SSE). Every line is prefixed with data:
data: {"id":"chatcmpl-123","choices":[{"delta":{"content":"Hel"}}]}
data: {"id":"chatcmpl-123","choices":[{"delta":{"content":"lo"}}]}
data: [DONE]
Tool calling and JSON mode
Pass tools in the OpenAI format and the model returns the function and arguments in message.tool_calls. The request below returned get_weather with {"city": "Paris"} in our test.
curl https://api.xhuoapi.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "deepseek-v3.2",
"messages": [{"role": "user", "content": "What is the weather in Paris? Use the tool."}],
"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"
}'
Send "response_format": {"type": "json_object"} and the model returns valid JSON only. Saying in the prompt that you want JSON makes the output more reliable.
curl https://api.xhuoapi.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "deepseek-v3.2",
"messages": [{"role": "user", "content": "Return this JSON exactly: {\"ok\": true}"}],
"response_format": {"type": "json_object"}
}'
Anthropic Messages format
Claude models accept Anthropic's request format and work with the Anthropic SDK. Code already written against the Anthropic SDK only needs a new base_url and key.
/v1/messages
Both auth headers were verified: x-api-key: YOUR_API_KEY or Authorization: Bearer YOUR_API_KEY. The Anthropic SDK adds the anthropic-version header shown below automatically.
curl https://api.xhuoapi.ai/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'
Python (anthropic SDK)
from anthropic import Anthropic
client = Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.xhuoapi.ai",
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
Embeddings
Same request and response format as OpenAI's /v1/embeddings. text-embedding-3-small returns 1536-dimension vectors.
/v1/embeddings
curl https://api.xhuoapi.ai/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model": "text-embedding-3-small", "input": "hello"}'
Error Handling
The API uses conventional HTTP status codes to indicate the result of a request.
| Status Code | Description |
|---|---|
200 |
Success |
400 |
Invalid request parameters |
401 |
API key missing or invalid |
429 |
Rate limit exceeded |
404 |
Path does not exist, usually a typo in the URL |
503 |
No upstream is currently available for this model, or the model name does not exist. Retry later or switch models |
500 |
Internal server error |
Example Error Response
{
"error": {
"code": "",
"message": "Invalid token (request id: ...)",
"type": "new_api_error"
}
}
The wording of error.message can change. Handle errors by HTTP status code rather than matching the message text.
Code Examples
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.xhuoapi.ai/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Hello"}
]
)
print(response.choices[0].message.content)
Node.js
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://api.xhuoapi.ai/v1'
});
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello' }]
});
console.log(response.choices[0].message.content);
cURL
curl https://api.xhuoapi.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello"}]
}'
Need help? Open the console or email support@xhuoapi.ai
© 2026 XHuoAPI. All rights reserved.