Api Usage
Carpathian AI API Quickstart

Connect to the Carpathian AI API in under five minutes. The API is OpenAI-compatible.

3 min read
3 views
Carpathian AI API Quickstart

Connect to the Carpathian AI API in under five minutes. The API is OpenAI-compatible, so any tool, SDK, or framework that speaks the OpenAI Chat Completions format works with Carpathian-hosted models out of the box: the official OpenAI Python and Node SDKs, LangChain, Open WebUI, and anything else that takes a base URL and an API key.

What you need

  • A Carpathian AI subscription (AI → Plans in the dashboard)
  • An AI instance with its cai_ API key (AI → Instances → New Instance)

Your key is bound to one model. You never specify the model in your requests, the key decides.

Base URL and API key

Base URL:  https://api.carpathian.ai/ai/v1
API key:   cai_your_api_key

That is the whole configuration. If your client demands a model name, use "default".

The API accepts every common base URL shape, so https://api.carpathian.ai/ai, the /v1 form above, or even the full chat-completions URL pasted as the base all route correctly.

Test your connection

Before wiring up your application, verify the key and base URL with the models endpoint. It costs no tokens and confirms auth, routing, and which model your key is bound to in one call:

curl https://api.carpathian.ai/ai/v1/models \
  -H "Authorization: Bearer cai_your_api_key"

A working setup returns the model behind your key in OpenAI list format. A 401 means the key is wrong or revoked, and a connection error means the base URL is wrong.

Send your first request

curl https://api.carpathian.ai/ai/v1/chat/completions \
  -H "Authorization: Bearer cai_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"model":"default","messages":[{"role":"user","content":"Hello"}]}'

The response is standard OpenAI format: your answer is in choices[0].message.content, and token counts are in usage.

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://api.carpathian.ai/ai/v1",
    api_key="cai_your_api_key",
)
resp = client.chat.completions.create(
    model="default",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)

Node.js (OpenAI SDK)

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.carpathian.ai/ai/v1",
  apiKey: "cai_your_api_key",
});
const resp = await client.chat.completions.create({
  model: "default",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);

Endpoints

  • POST /ai/v1/chat/completions is the primary chat endpoint.
  • POST /ai/chat/completions, /ai/chat, /ai/v1, and /ai/v1/completions are aliases that take the same payload.
  • GET /ai/v1/models lists the model behind your key, in OpenAI format. Use it to test your connection.

Streaming is not supported; the full response returns at once.

Quick troubleshooting

  • 401: the cai_ key is missing, mistyped, or revoked.
  • 402: out of tokens. Top up at AI → Plans → Token Packs.
  • 403: your IP is not on the instance allowlist, or the instance is locked.
  • 429: rate limit hit (default 60 requests per minute, configurable).

For billing, security features, and the full error reference, see the complete Carpathian AI API documentation.