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#

BashSyntax highlighted
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.

PythonSyntax highlighted
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.

JavaScriptSyntax highlighted
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.

JSONSyntax highlighted
{
  "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#

PurposeMethod 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 CompletionsPOST 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
EmbeddingsPOST https://api.clssai.com/v1/embeddings
RerankingPOST https://api.clssai.com/v1/rerank
Image generationPOST 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 synthesisPOST https://api.clssai.com/v1/audio/speech
TranscriptionPOST https://api.clssai.com/v1/audio/transcriptions
Video pass-through (lightly tested)POST https://api.clssai.com/v1/videos
Key balanceGET https://api.clssai.com/v1/balance
Key recordGET https://api.clssai.com/v1/key
Credits summaryGET https://api.clssai.com/v1/credits
Generation lookupGET https://api.clssai.com/v1/generation
Anthropic MessagesPOST 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 generationPOST https://api.clssai.com/v1beta/models/{model}:generateContent
Gemini streamingPOST https://api.clssai.com/v1beta/models/{model}:streamGenerateContent
Gemini model list (public)GET https://api.clssai.com/v1beta/models
Request logsGET 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 /v1 in 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/model ID in production. Exact bare aliases are supported, but :free and :batch variants must include the full name; see Models & pricing.
  • Use the Anthropic SDK without /v1 in its base_url; see Native protocols.
  • In streams, check that choices is non-empty before reading the first choice.
  • Use the cf-ray response header when asking support to trace an inference request.
Need a hand?

Find answers to common questions or diagnose a failed request.

Frequently asked questions →Troubleshoot errors →