https://api2.laozhang.ai to call LaoZhang API. OpenAI clients use a base URL ending in /v1; Google Gen AI and Anthropic clients use the host root. Choose the format your application already uses, then select a model available to your API key’s group.
Get an API key
Create a model API key in Token management. Check its group, balance, and model permissions in Models and pricing. Set the key as an environment variable in the terminal where you will run the examples:gpt-5.4-mini for text, gemini-3.8-flash for native Gemini text, and gpt-image-2-vip for images. If your token group uses another model, copy its exact ID from the console.
Send a text request
Chat Completions accepts amessages array. Use Bearer authentication and a JSON request body:
choices[0].message.content. For this prompt, expect connected. Replace the message content with your own prompt to use the same request in your application.
OpenAI SDK
The OpenAI SDK builds the endpoint path, so set its base URL tohttps://api2.laozhang.ai/v1 without adding /chat/completions.
- Python
- Node.js
Install the SDK:
Responses API
The Responses API usesinput in the request and output in the response. Its request body is different from Chat Completions.
- cURL
- Python
text values from content items whose type is output_text within the output array. The SDK’s output_text helper does this for you. Other output items can contain reasoning or tool calls, so the first item is not necessarily the text answer.
For applications that need conversation history, retain the messages your next request requires. Server-side state, previous_response_id, and built-in tools depend on the selected model and endpoint. See the OpenAI Responses reference for upstream field definitions and the Data Policy for data handling.
Generate an image
Send a JSON prompt to the Images generation endpoint:data[0].b64_json. Install Pillow with python -m pip install pillow, then save the image:
Edit an image
Place a reference image namedinput.png in your current directory. Upload it with the instructions as multipart form data:
@ syntax uploads the file contents. Let cURL set the multipart content type and boundary; do not add Content-Type: application/json to this request.
Install Pillow with python -m pip install pillow if needed, then save the returned image:
Call Gemini with its native API
Gemini’s native API usescontents[].parts[] rather than OpenAI messages:
candidates[].content.parts[]. If no text is present, inspect finishReason and promptFeedback.
For the Google Gen AI SDK, use the host root https://api2.laozhang.ai with api_version="v1beta". The SDK adds the model path and API key header. The Gemini reference includes a complete Python example, both authentication header options, and image-input instructions.
Call Claude with its native API
Applications built around Anthropic content blocks use:https://api2.laozhang.ai. Follow the Claude integration guide for the model ID, required headers, and message format. Native Anthropic content blocks and OpenAI message objects use different request and response structures.
More API operations
- Models API: discover model IDs for your application.
- Embeddings: turn text into vectors.
- Audio transcription: upload audio and receive a transcript.
- Moderation: submit content for classification.
Resolve common errors
Correct invalid requests before retrying. For temporary failures, use bounded backoff and avoid stacking SDK retries with application retries.
A client timeout does not cancel generation or establish whether a charge occurred. Check call logs before resubmitting an image request. If you need support, provide the time, model, endpoint, token group, and redacted error. Billing and refunds follow the Terms.
Use these docs in an AI coding tool
Give your coding assistant the target model, task, and one of these documentation links:- skill.md: integration instructions for coding tools.
- llms.txt: an index for finding the relevant page.
- llms-full.txt: the full public documentation export.