Skip to main content
LaoZhang API serves text models in three request formats: OpenAI-compatible Chat Completions, Anthropic Messages, and Gemini’s native generateContent. For a new project, use Chat Completions; it works with the largest number of text models.

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.
The format also decides the token group of your API key:
  • Anthropic Messages: a token in the Claude Code group.
  • OpenAI-compatible and Gemini native: a token in the default group.
Both groups have the same prices. If one application sends both formats, create one token in each group. Each format has its own endpoint:
When you use an SDK, set the OpenAI SDK’s base URL to 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.2
  • deepseek-v4-pro
  • deepseek-v4-flash
  • Kimi models such as kimi-k3
The request and response structures differ, so switching formats means changing both the request code and the parser: 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 the default 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, and claude-haiku-5-5 charge 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 the o3-pro series 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 high thinking 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 the default group. Then export the key:
These examples send one message to 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 as chat.mjs, and run it with node chat.mjs.
The reply should be 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.content in order and skip chunks that have no choices or content. The stream ends with data: [DONE]. Stream a response has complete cURL and Python examples and the raw events.
  • Anthropic Messages: text arrives as delta.text in content_block_delta events, and the reply is complete only after message_stop. See Stream the response.
  • Gemini native: replace generateContent with streamGenerateContent and add ?alt=sse. Each event carries a partial response with candidates; 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 -N to turn off output buffering.

Troubleshoot common errors

  • 404 with /v1/v1 in the URL: the SDK base URL repeats part of the path. Use https://api.laozhang.ai/v1 for the OpenAI SDK and https://api.laozhang.ai for 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-pro works only through Responses, and GPT models do not accept Gemini native requests. See model availability.
  • 400: a Messages request without max_tokens is 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_calls and finish_reason.
    • Messages: read content[] by block type instead of taking content[0].
    • Gemini: check finishReason and promptFeedback.
  • 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_reason of length.
    • Messages: stop_reason of max_tokens.
    • Gemini: finishReason of MAX_TOKENS.
  • 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

  1. Pin the model ID and protocol in configuration, and test a model change like any other release.
  2. 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.
  3. Test normal requests, streaming, and error handling. Keep retries in one layer, either the SDK or your application.
  4. In call logs, check each request’s model, input and output tokens, and charge.