Skip to main content

Configure the connection

Complete the quickstart to obtain a model API key and service address. These guides use three environment variables:
Replace all three placeholders. API_BASE_URL includes one /v1, with no trailing slash. Preserve any deployment path prefix. Use the HTTPS address supplied by your administrator for production requests. Some third-party clients add /v1 automatically. Check their URL convention. For HTML responses or 404 errors, first check the hostname, path prefix, and duplicate /v1 segments.

Authenticate requests

Send Authorization: Bearer YOUR_API_KEY. Read the key from environment variables or a server-side secret manager. Console cookies and management credentials are not model API keys. Keep keys out of browser bundles; route browser interactions through your own server.

Choose a model and endpoint

List models and use the exact data[].id. Visibility depends on account access, key permissions, groups, and deployment configuration. Listing a model does not guarantee support for every protocol.
  • Use Chat Completions for ordinary conversations, passing message history with each request.
  • Use Responses when supported by your model. Changing only the URL is insufficient: request and response shapes differ.
  • Confirm image, audio, tool calling, structured output, reasoning, and streaming support separately for the model and channel.
Start with a minimal text request and add optional parameters one at a time. Do not copy another provider’s model IDs or default parameters without checking support.

Move an existing client

Keep application prompts unchanged at first. Replace the service address, API key, and model ID, then compare successful responses, error handling, and timeout behavior. Check files, batches, background tasks, response retrieval, and other platform features separately before relying on them through a compatible gateway.

Build an application

Multi-turn conversations · Tool calling · Structured output · Image understanding 简体中文