Getting started
Quickstart
Send your first OpenAI-compatible CLSSAI request from a server in minutes.
On this page
This page is for backend developers who have a CLSSAI API key and want a working first request in under ten minutes.
CLSSAI exposes an OpenAI-compatible API. Use https://api.clssai.com/v1 as the SDK base URL and send your key as a Bearer token.
Run every example on a server, never in browser JavaScript. Some inference responses do carry permissive CORS headers, so a browser call can succeed and expose your key to every visitor — treat that as a leak, not a supported path.
Send a request with curl#
curl https://api.clssai.com/v1/chat/completions \
-H "Authorization: Bearer $CLSSAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-nano",
"messages": [{"role": "user", "content": "Reply with exactly: CLSSAI first call works."}],
"max_tokens": 128,
"stream": false
}'Send the same request with Python#
Install the official client with pip install openai, then run this on your server.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.clssai.com/v1",
api_key=os.environ["CLSSAI_API_KEY"],
)
response = client.chat.completions.create(
model="openai/gpt-5.4-nano",
messages=[{"role": "user", "content": "Reply with exactly: CLSSAI first call works."}],
max_tokens=128,
)
print(response.choices[0].message.content)Send the same request with JavaScript#
Install the official client with npm install openai. This Node.js example reads the key from the server environment.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.clssai.com/v1",
apiKey: process.env.CLSSAI_API_KEY,
});
const response = await client.chat.completions.create({
model: "openai/gpt-5.4-nano",
messages: [{ role: "user", content: "Reply with exactly: CLSSAI first call works." }],
max_tokens: 128,
});
console.log(response.choices[0].message.content);Inspect the response#
The response body is passed through from the upstream API. A typical successful response includes an ID, the resolved model, choices, and usage. usage.cost is present only when the upstream API reports it.
{
"id": "gen_example",
"object": "chat.completion",
"model": "openai/gpt-5.4-nano",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "CLSSAI first call works."},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 18, "completion_tokens": 8, "total_tokens": 26}
}If the request fails, compare the status and both supported error shapes on Errors & rate limits.
Base URLs and primary endpoints#
| Purpose | Method and endpoint |
|---|---|
| OpenAI-compatible model list (public) | GET https://api.clssai.com/v1/models |
| Single model record (public) | GET https://api.clssai.com/v1/models/{author}/{slug} |
| Model count (public) | GET https://api.clssai.com/v1/models/count |
| Embedding model list (public) | GET https://api.clssai.com/v1/embeddings/models |
| Image model list (public) | GET https://api.clssai.com/v1/images/models |
| Video model list (public) | GET https://api.clssai.com/v1/videos/models |
| Chat Completions | POST https://api.clssai.com/v1/chat/completions |
Responses API (verified; data-only SSE, dispatch on JSON type) | POST https://api.clssai.com/v1/responses |
| Legacy Completions (text models; wrong-modality models are rejected) | POST https://api.clssai.com/v1/completions |
| Embeddings | POST https://api.clssai.com/v1/embeddings |
| Reranking | POST https://api.clssai.com/v1/rerank |
| Image generation | POST https://api.clssai.com/v1/images |
Image edits (multipart translated to JSON; no mask; 8 MB total; always b64_json) | POST https://api.clssai.com/v1/images/edits |
| Speech synthesis | POST https://api.clssai.com/v1/audio/speech |
| Transcription | POST https://api.clssai.com/v1/audio/transcriptions |
| Video pass-through (lightly tested) | POST https://api.clssai.com/v1/videos |
| Key balance | GET https://api.clssai.com/v1/balance |
| Key record | GET https://api.clssai.com/v1/key |
| Credits summary | GET https://api.clssai.com/v1/credits |
| Generation lookup | GET https://api.clssai.com/v1/generation |
| Anthropic Messages | POST https://api.clssai.com/v1/messages |
| Anthropic token count (not billed) | POST https://api.clssai.com/v1/messages/count_tokens |
| Anthropic model list (public) | GET https://api.clssai.com/anthropic/v1/models |
| Gemini generation | POST https://api.clssai.com/v1beta/models/{model}:generateContent |
| Gemini streaming | POST https://api.clssai.com/v1beta/models/{model}:streamGenerateContent |
| Gemini model list (public) | GET https://api.clssai.com/v1beta/models |
| Request logs | GET https://api.clssai.com/key/<key>/logs.json |
OpenAI-compatible calls use the base URL https://api.clssai.com/v1 and accept Bearer, x-api-key, or a ?key= query parameter. Prefer a header: a key in the URL leaks through referrers, proxy logs, and browser history. The Anthropic SDK base URL is https://api.clssai.com without /v1; calls accept x-api-key or Bearer and require anthropic-version: 2023-06-01. Gemini uses https://api.clssai.com/v1beta with x-goog-api-key or ?key= and does not accept Bearer authentication.
Common mistakes#
- Include
/v1in the OpenAI SDK base URL. - Keep the API key on your server. A browser call can succeed and will expose the key to anyone who opens the page.
- Prefer a complete
author/modelID in production. Exact bare aliases are supported, but:freeand:batchvariants must include the full name; see Models & pricing. - Use the Anthropic SDK without
/v1in itsbase_url; see Native protocols. - In streams, check that
choicesis non-empty before reading the first choice. - Use the
cf-rayresponse header when asking support to trace an inference request.
Find answers to common questions or diagnose a failed request.
Frequently asked questions →Troubleshoot errors →