Skip to main content
This guide uses the OpenAI-compatible Chat Completions endpoint. Run the examples in a terminal or on a server; no SDK installation is required.

1. Prepare your API address and key

  1. Sign in to the console provided by your administrator.
  2. Open the API Keys page (console path /keys), then create and copy an API key.
  3. Confirm that your account and key are active and can access the intended model.
  4. Confirm your API base URL using the address supplied by your administrator or console.
The following commands work in Bash / Zsh on macOS, Linux, or WSL. Replace the example address with your own, then set the environment variables:
In this guide, API_BASE_URL includes one /v1 and has no trailing /. If your deployment uses a path prefix, preserve it, for example https://example.com/gateway/v1. Do not use the documentation domain or add /v1 twice. Replace YOUR_API_KEY locally. Do not commit a real key to Git, put it in browser code, or expose it in screenshots. Do not substitute a sign-in session or management credential for a model API key.

2. List available models

The response contains model entries in the data array. Each entry’s id is the model ID to use in requests. Choose a chat model that supports Chat Completions and use its exact ID, not its display name. Replace the placeholder below with that model ID. The following requests use this variable:
If the list is empty or you are unsure which model supports chat, ask your deployment administrator to confirm the channel configuration, model capabilities, and key permissions.

3. Send your first chat request

Choose one of the three options below, using the environment variables you set above. Sending a request invokes the actual model.

cURL

Requires cURL 7.76 or later. Use the original model ID returned by the model list.

Python

Requires Python 3 and uses only the standard library. Save the code as chat.py and run python3 chat.py in the terminal where you set the environment variables.

TypeScript

Requires Node.js 22.18 or later and uses built-in fetch; no dependencies are required. Save the code as chat.mts and run node chat.mts in the terminal where you set the environment variables.

4. Check the result

On success, cURL prints JSON with the reply at choices[0].message.content. The Python and TypeScript examples print that text directly, for example:
The exact text varies by model. If a request fails, inspect its HTTP status and the request logs in your console. Do not include your complete API key when asking for help.

Troubleshooting

These are troubleshooting directions; actual status codes and error messages can vary by upstream service.

Next steps

Configure the same API base URL, key, and model ID in your server-side application. When integrating an existing SDK, check whether it expects a base URL containing /v1 or a full endpoint URL. About the project and address conventions · 切换到简体中文 Integration guides · API reference