Quick start
Set the base URL
https://api.alian.com/v1 for the OpenAI SDK, https://api.alian.com for the Anthropic SDK.
curl https://api.alian.com/v1/chat/completions \ -H "Authorization: Bearer alk-your-key" \ -H "Content-Type: application/json" \ -d '{ "model": "glm-5.3-flash-abliterated", "messages": [{"role": "user", "content": "Hello!"}], "stream": true }'
from openai import OpenAI client = OpenAI( api_key="alk-your-key", base_url="https://api.alian.com/v1", ) stream = client.chat.completions.create( model="glm-5.3-flash-abliterated", messages=[{"role": "user", "content": "Hello!"}], stream=True, ) for chunk in stream: print(chunk.choices[0].delta.content or "", end="")
import OpenAI from "openai"; const client = new OpenAI({ apiKey: "alk-your-key", baseURL: "https://api.alian.com/v1", }); const stream = await client.chat.completions.create({ model: "glm-5.3-flash-abliterated", messages: [{ role: "user", content: "Hello!" }], stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); }
Authentication
Send your key with every request, as a bearer token or in x-api-key. Keys start with alk-.
Endpoints
Three paths on api.alian.com. The OpenAI SDK reaches them from its base URL; the Anthropic SDK adds /v1/messages itself.
/v1/chat/completionsChat, in the OpenAI format./v1/messagesMessages, in the Anthropic format./v1/modelsThe models your key can call.from anthropic import Anthropic client = Anthropic( api_key="alk-your-key", base_url="https://api.alian.com", ) message = client.messages.create( model="glm-5.3-flash-abliterated", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], ) print(message.content[0].text)
curl https://api.alian.com/v1/messages \ -H "x-api-key: alk-your-key" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "glm-5.3-flash-abliterated", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello!"}] }'
Models
Open models on our partner's GPUs, with zero data retention. Pass the ID as model.
GET /v1/models with your key lists the IDs it can call. Prices are on the pricing section.
Streaming
Set stream to true and the reply arrives as server-sent events, in the endpoint's own format: chat completion chunks from /v1/chat/completions, Messages events from /v1/messages. Both SDKs read them for you, as in the quick start.
For token counts on a chat completions stream, send "stream_options": {"include_usage": true}. The stream then ends with one usage chunk, its choices empty, right before [DONE]: the same counts the request is billed with.
Errors
An error comes back as an HTTP status and a JSON body in the endpoint's format, with an x-request-id header to quote if you write to us.
{
"error": {
"message": "Invalid API key.",
"type": "authentication_error",
"param": null,
"code": "invalid_api_key"
}
}
| Status | Code | What to do |
|---|---|---|
| 400 | missing_model, invalid_body | Check the body: it needs a model and messages. |
| 401 | missing_api_key, invalid_api_key | Check the key you sent. |
| 402 | insufficient_credit | Top up your balance in the dashboard. |
| 429 | api_key_rpm_exceeded, api_key_concurrency_exceeded | Wait the seconds in Retry-After, then retry. The x-ratelimit-* headers say which limit and when it resets. |
| 502, 503 | upstream_failed, no_supply | Nothing was charged. Retry after the seconds in Retry-After, and back off if it repeats. |