Quick Start

Applies to: Developers Last updated: 2026-07-14

This guide walks you through your first API call from scratch, getting a response from the model in under 5 minutes.

The API address is YOUR_API_BASE_URL, with route prefix /v1, and authentication via Authorization: Bearer sk-xxx. You can also check the currently available Base URL on the "API Keys" page in the console.


Prerequisites

Before you begin, make sure you have:

  • ✅ A platform account (register an organization account yourself, or complete registration as a sub-user with an activation code)
  • ✅ Available balance / quota on your account (actual charges are always deducted from the owning organization's balance; when quota is 0, contact your owning organization)

Step 1: Get an API Key

Under v2, API Keys are created by the organization in the console:

  • If you are an organization (top-level user):

    1. Log in to the console
    2. Go to the "API Keys" page
    3. Click "Create API Key", give it a name (e.g. my-first-key), and optionally bind it to a routing group (if not bound, the default route is used)
    4. Copy and save the Key immediately after creation (in the form sk-xxxxxxxx); it is shown in full only once
  • If you are a sub-user: you can create Keys yourself on the "API Keys" page (routing groups are limited to the scope authorized by the organization); the organization can also create and distribute Keys on your behalf.

    Sub-users can create Keys themselves on the "API Keys" page (routing group is optional and can only be chosen within the scope authorized by the organization); the organization can also create and distribute them on your behalf.

⚠️ An API Key is equivalent to a password—do not commit it to code repositories or share it publicly.

Once you have the Key, you still need to determine what to put in the model field—see the next step.


Step 2: Get the Model Call Name

After logging in to the console, view the available models on the "Call Guide" page and copy the call name (e.g. claude-sonnet-4-6). You can also get it from the Model Marketplace or via the /v1/models API. In most cases, using the model name directly is sufficient.

If the organization has enabled group-identifier routing, the "Call Guide" page will additionally display call names with a group identifier (e.g. 5MHXZWKA/gpt-4o), which can target a specific group. When it is not enabled, calls with a group-identifier prefix are rejected.

For details on routing rules, see Call Guide and Routing. The examples in this guide use the model name.


Step 3: Send Your First Request (curl)

Replace YOUR_API_KEY in the command below with your Key, replace model with the call name you copied from the Call Guide, and run it in your terminal:

curl YOUR_API_BASE_URL/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "user", "content": "用一句话介绍你自己"}
    ]
  }'

If everything works, you will receive a response similar to this:

{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "我是一个 AI 助手,可以帮你解答问题、编写代码、处理文本。"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 20,
    "total_tokens": 32
  }
}

Congratulations, you've completed your first call!


Step 4: Call from Python

For something closer to real development, use the official OpenAI SDK (you only need to change base_url and api_key):

from openai import OpenAI
 
client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="YOUR_API_BASE_URL"
)
 
resp = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[
        {"role": "user", "content": "用一句话介绍你自己"}
    ]
)
 
print(resp.choices[0].message.content)

Install dependencies: pip install openai


Quick Troubleshooting

Symptom Possible Cause Solution
401 Unauthorized Wrong Key or missing Bearer Check the Authorization header format
403 / insufficient balance or quota The owning organization's balance is 0, or the sub-user has hit the quota cap Contact the owning organization to top up / raise the quota
Model unavailable / not found Wrong call name, or not within your account's available scope Copy the call name from the Call Guide and confirm the available scope
"Group unreachable" with group identifier The group is out of the available scope or the channel is unavailable, or group-identifier routing is not enabled See Call Guide and Routing
429 Rate limit / quota exhausted Reduce request frequency; see Error Codes and Troubleshooting

For the full list of error codes, see Error Codes and Troubleshooting.


Next Steps