Quickstart: API keys and models
Discover available models and send your first text request.
1. Create an API key
Open the AIMirrorX console, sign in, and create a token in the token/API key management section. Configure its group, model permissions, quota and expiry as needed. Exact labels depend on the current console.
Keep keys secret in server-side environment variables. Do not put them in frontend code, Git repositories or public screenshots. Revoke and replace a key if it is lost or exposed. All examples use placeholder credentials.
export AIMIRRORX_API_KEY='YOUR_API_KEY'2. List available models
curl https://api.aimirrorx.com/v1/models \
-H "Authorization: Bearer $AIMIRRORX_API_KEY"Choose an ID from the response's data[].id that is visible to your token and supports the intended protocol. Replace MODEL_ID_FROM_V1_MODELS below with that ID. Do not assume that upstream model names mentioned in references are available.
3. Send a Chat Completions request
curl https://api.aimirrorx.com/v1/chat/completions \
-H "Authorization: Bearer $AIMIRRORX_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"MODEL_ID_FROM_V1_MODELS","messages":[{"role":"user","content":"你好"}]}'For models supporting streaming, add "stream": true and read the SSE stream with curl -N. A disconnected stream does not prove that the upstream request was never executed. Check usage and request logs before retrying automatically to avoid duplicate charges.
4. Use an SDK
OpenAI-compatible SDKs usually expect base_url to be https://api.aimirrorx.com/v1 and append /chat/completions themselves. Do not provide the complete endpoint or duplicate /v1. If your SDK adds /v1 itself, use the service origin instead.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["AIMIRRORX_API_KEY"],
base_url="https://api.aimirrorx.com/v1")
response = client.chat.completions.create(
model="MODEL_ID_FROM_V1_MODELS",
messages=[{"role": "user", "content": "你好"}],
)
print(response.choices[0].message.content)Troubleshooting
401: check the key, authentication header and expiry. Console sign-in credentials are not API keys.403or no available channel: check the token's group, model permissions and channel support.404: check for a duplicated/v1or an accidental documentation-domain URL.429: follow server rate-limit guidance and use bounded backoff retries.5xxor timeouts: record the time, model, endpoint, any request ID and a redacted error. Contact the support entry shown in the console without including your real key.