Skip to main content
Point the OpenAI SDK at https://api2.laozhang.ai/v1 and authenticate with a LaoZhang API key. Choose the exact model ID from Models and pricing, where you can also check your token group’s access and current prices.

Configure the client

Create a model API key in Token management, set the LAOZHANG_API_KEY environment variable, and install the Python SDK:
This example sends a message to gpt-5.4-mini and prints the reply:
Keep /v1 in the SDK base URL. The SDK appends the endpoint path, so do not include /chat/completions in base_url. For Node.js and cURL examples, see the API integration guide.

Choose an endpoint

Chat Completions

Use Chat Completions for applications that send a messages array and read replies from choices:
For multi-turn conversations, send the relevant messages in order with each request. See the Chat Completions reference for message fields and response handling.

Responses

Responses accepts input and returns an output array. The Python SDK provides response.output_text for text replies:
Use the Responses examples to make a text request. If you are switching from Chat Completions, update both the request body and the response parser. Server-side conversation state and built-in tools depend on the model and endpoint; they are not implied by basic text-generation access.

Images

Use the Images API when you need an image file:
Generation takes a JSON prompt; editing uploads a reference image as multipart data. The Images reference includes complete cURL and Python examples for both operations, including how to save the result.

Move an existing integration

Update the API key, base URL, and model ID together. A model name available through OpenAI may differ from the name or group available in LaoZhang API. Start with the required request fields, then add the options your application uses. Sampling controls, output limits, structured output, and tool settings vary by model. When a request returns an unsupported-parameter error, remove or adjust the named field using the model’s documentation. Keep retry handling in one place. If both your SDK and application retry requests, a single action can produce several API calls. For timeouts or unexpected charges, review the call logs with the request time and model ID. The LaoZhang model catalog helps you find available models. The official OpenAI catalog describes upstream models and capabilities; LaoZhang API access and prices are listed in the console.