Choose a protocol
- New project, or a client built on the OpenAI SDK or format: use OpenAI-compatible Chat Completions. See the OpenAI protocol reference.
- Anthropic SDK, Claude Code, or another Messages client: use Anthropic Messages. See the Claude protocol reference.
- Google Gen AI SDK, or code that relies on Gemini’s native fields: use the Gemini format. See the Gemini protocol reference.
- Anthropic Messages: a token in the
Claude Codegroup. - OpenAI-compatible and Gemini native: a token in the
defaultgroup.
https://api.laozhang.ai/v1. The Anthropic SDK and the Google Gen AI SDK take the host root, https://api.laozhang.ai, and add the path themselves.
The Anthropic Messages endpoint serves the models marked for it in the pricing configuration, all through the Claude Code token group, including:
- Claude models, listed again from October 18, 2026. See Claude model limits before you switch.
glm-5.2deepseek-v4-prodeepseek-v4-flash- Kimi models such as
kimi-k3
A model marked with two formats, such as
gemini-3.8-flash (Chat Completions and Gemini native), accepts either one, but each request must use a single format’s fields.
Common text models
Prices below come from LaoZhang API’s public pricing as of October 18, 2026. They are list prices for thedefault token group, in US dollars per 1M tokens. The model catalog has cache-read prices, other models, and other token groups.
- GPT-6 models, GPT-5.6 models,
gpt-5.4, andclaude-haiku-5-5charge a higher tier for long inputs. The catalog’s tiered pricing table lists the thresholds and prices. - To choose among the three GPT-6 models, and for OpenAI’s rules on their parameters and tool calling in Chat Completions, see the GPT-6 launch announcement.
- The OpenAI models in the table also work with the Responses endpoint,
POST /v1/responses, and theo3-proseries supports only Responses. - GPT-6 and GPT-5.6 models can call tools through both Chat Completions and Responses (since November 4, 2026); see function calling. For GPT-6.1 Sol’s other parameter differences, see the GPT-6.1 Sol launch announcement. See OpenAI models on LaoZhang API for examples.
- Send the
highthinking level when Gemini 4 Argon needs to reason deeply. For its thinking levels and launch pricing, see the Gemini 4 Argon launch announcement. - To send images to a vision model, see the Image understanding API.
Send your first request
Create an API key in Token management. Set its billing mode to Usage first (按量优先, recommended) or Usage-based (按量计费), and make sure its token group can call the model you want. The examples below use the OpenAI-compatible format, so choose thedefault group. Then export the key:
gpt-5.4-mini in the OpenAI-compatible format. Install the SDK before you run them:
- Python: run
python -m pip install openai. - Node.js: run
npm install openai, save the code aschat.mjs, and run it withnode chat.mjs.
- cURL
- Python
- Node.js
connected. To try another model, change model to an ID whose Endpoints include OpenAI-compatible. The SDK examples turn off automatic retries so that your application decides when to send a request again.
Stream the reply
Add"stream": true to receive the reply as server-sent events while the model writes it. Each format streams a little differently:
- OpenAI-compatible: append each
choices[0].delta.contentin order and skip chunks that have nochoicesorcontent. The stream ends withdata: [DONE]. Stream a response has complete cURL and Python examples and the raw events. - Anthropic Messages: text arrives as
delta.textincontent_block_deltaevents, and the reply is complete only aftermessage_stop. See Stream the response. - Gemini native: replace
generateContentwithstreamGenerateContentand add?alt=sse. Each event carries a partial response withcandidates; see Stream the reply. - If the connection closes before the end marker, the text you received is incomplete; treat the request as failed or send it again. With cURL, add
-Nto turn off output buffering.
Troubleshoot common errors
- 404 with
/v1/v1in the URL: the SDK base URL repeats part of the path. Usehttps://api.laozhang.ai/v1for the OpenAI SDK andhttps://api.laozhang.aifor the Anthropic and Google Gen AI SDKs. - Model not available, 403, or 404: copy the exact model ID from the catalog, confirm that your key’s token group includes the model, and check that the model supports the format you are sending. For example,
o3-proworks only through Responses, and GPT models do not accept Gemini native requests. See model availability. - 400: a Messages request without
max_tokensis a common cause. Otherwise, go back to the minimal request, then add optional fields one at a time and fix the field the error names. - 401: the API key is wrong, the header is malformed, or the environment variable is not set in the current shell.
- Empty reply:
- Chat Completions: check
message.tool_callsandfinish_reason. - Messages: read
content[]by blocktypeinstead of takingcontent[0]. - Gemini: check
finishReasonandpromptFeedback.
- Chat Completions: check
- Truncated reply: any of these values means the reply hit the output limit. Raise the model’s output limit or shorten the input.
- Chat Completions:
finish_reasonoflength. - Messages:
stop_reasonofmax_tokens. - Gemini:
finishReasonofMAX_TOKENS.
- Chat Completions:
- 429: read the error body to tell rate or concurrency limits apart from insufficient balance. If you still have balance, see why a request can fail with remaining balance.
Before you go to production
- Pin the model ID and protocol in configuration, and test a model change like any other release.
- Run a sample of your own prompts through two or three candidate models and compare answer quality, latency, and token usage. Choose a model describes the comparison.
- Test normal requests, streaming, and error handling. Keep retries in one layer, either the SDK or your application.
- In call logs, check each request’s model, input and output tokens, and charge.
Related documentation
- OpenAI protocol: Chat Completions
- Use OpenAI models with LaoZhang API
- Claude protocol: Anthropic Messages
- Gemini protocol: generateContent
- API integration guide: keys, base URLs, Responses, and images
- Model catalog and pricing
- Upstream documentation: OpenAI text generation, Anthropic Messages API, and Gemini text generation