Skip to content

Build with Ablix.

Create an organization key and send a text request using the OpenAI-compatible Chat Completions API.

Quickstart

  1. Sign in to the console. Signing up creates your organization; you can rename it in settings.
  2. Create a key in API keys. You must be an owner or admin. The secret is shown once, so save it securely.
  3. Make sure the key creator has enough credits. Organization-key requests charge the key creator’s personal balance; organizations do not have a shared wallet yet.

Each request’s total cost is rounded up to the nearest $0.001. For example, an estimated cost of $0.00015 is charged as $0.001. The playground estimate can differ from the charge shown in request activity.

Set up your environment

Replace YOUR_ABLIX_HOST with your deployment’s API host, YOUR_API_KEY with your key, and MODEL_ID_FROM_THE_CATALOGUE with an ID from the model list below. The address shown here is a placeholder, not a live public server.

Environment variables
export ABLIX_BASE_URL="https://YOUR_ABLIX_HOST/v1"
export ABLIX_API_KEY="YOUR_API_KEY"
export ABLIX_MODEL="MODEL_ID_FROM_THE_CATALOGUE"

Run these examples on your server or in a local terminal. Never put the API key in a browser app. The cURL example also requires jq.

Send a message

JavaScript
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.ABLIX_API_KEY,
  baseURL: process.env.ABLIX_BASE_URL,
});

const reply = await client.chat.completions.create({
  model: process.env.ABLIX_MODEL,
  messages: [{ role: "user", content: "Explain an API in one sentence." }],
  max_tokens: 256,
});

console.log(reply.choices[0]?.message.content);

Read the answer from choices[0].message.content. The usage field contains token counts.

Authentication

Both API endpoints require an Authorization header with a Bearer token. A console sign-in cookie does not replace an API key for these requests.

Request header
Authorization: Bearer YOUR_API_KEY

A key belongs to the organization selected when it was created. Store it in an environment variable or secret manager. If it is exposed, revoke it in the console, create a replacement, and update your integration.

Models

List the models available through the API first. Use an id from the response exactly as returned. The API catalogue can be smaller than the chat catalogue: it lists only models with API access and pricing configured.

GET /v1/models
curl "$ABLIX_BASE_URL/models" \
  -H "Authorization: Bearer $ABLIX_API_KEY"

The response has the shape { object: "list", data: [...] }. An empty list means that no API models are currently available. Do not substitute a model name from another service for the public ID.

Supported request fields

FieldDescription
modelRequired public ID from GET /v1/models.
messagesFrom 1 to 100 text messages. Roles: system, user, assistant. Each content value is a nonempty string. Serialized messages must fit within 256,000 characters.
max_tokensFrom 1 to 4096 tokens; defaults to 4096. Available credits may lower the limit. You can use max_completion_tokens instead, but never send both fields.
temperatureOptional number from 0 to 2. Omit it to use the model’s default.
streamDefaults to false. Set true for streamed output. Add stream_options: { include_usage: true } to receive token counts in a final usage event.

The current API supports text Chat Completions. Images, audio, tools, embeddings, and other API surfaces are not supported. Unknown fields are rejected; SDK compatibility does not mean every OpenAI feature is available.

Streaming

Add stream: true to receive text as it is generated. This example uses the client created in Quickstart. The SDK reads the server-sent events for you.

JavaScript · streaming
const stream = await client.chat.completions.create({
  model: process.env.ABLIX_MODEL,
  messages: [{ role: "user", content: "Write a short welcome message." }],
  max_tokens: 256,
  stream: true,
  stream_options: { include_usage: true },
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta.content ?? "");
}

When reading SSE directly, take text from choices[0].delta.content. Finish events contain no text; a separate usage event is sent only with include_usage: true. The stream ends with data: [DONE]. Treat a dropped connection as an incomplete answer.

Errors

Check the HTTP status and error object before reading a completion. Keep keys and full prompts out of error logs.

  • 400 — invalid request: check JSON, required fields, the token limit, and model ID. For 413, keep the request body within 1 MiB; for 415, use Content-Type: application/json.
  • 401 — access error: check the key and its revocation status. A key also stops working if its creator loses membership or admin access, or is banned. Do not retry with the same invalid credential.
  • 402 — insufficient credits: check the key creator’s personal balance before retrying.
  • 409 — credits are reserved or need review: wait for the current reply to finish. Contact support if the state does not clear.
  • 502 or 503 — temporary service failure: use bounded retries with increasing delays. A retry after an interruption may create another billable request.

Organizations

Signing up gives you an organization with its own ID and name. Organization settings let you manage your team; switching organizations changes the context for its keys and members.

  • Owners manage the organization and ownership transfers. Admins manage members and keys within their permissions.
  • To invite someone, enter their email and role. Share the invitation link with that person; automatic email delivery depends on the deployment’s configuration.
  • The recipient signs in with the invited email. That email must be verified before they can accept. Invitations can be cancelled; an expired link needs a new invitation.
  • The organization ID helps identify the organization in support and management. It does not grant access by itself. Inviting members does not make personal chats shared.
Go to your organization

Data handling

Chat saves conversations and revisions on the server. API requests and the playground record request metadata for usage and credits, but do not create chat history. This distinction is not a zero-retention promise for every processing system.

Read about data handling