API Reference

BelugAPI Documentation

One gateway, every leading AI model. BelugAPI exposes an OpenAI-compatible REST API — change one line of code and access 200+ models at up to 70% below official prices.

OpenAI-compatible. BelugAPI speaks the OpenAI wire format. Any SDK or tool that works with OpenAI works with BelugAPI — just swap the base_url and your API key.

Base URL

All API requests are made to the following base URL.

https://api.belugapi.com/v1

Authentication

All requests (except GET /v1/models and GET /v1/health) require a Bearer token in the Authorization header. API keys start with bapi_.

Authorization: Bearer bapi_your_api_key_here
Get your API key from the dashboard. Keep it secret — never expose it in client-side code.

Endpoints

BelugAPI provides the following endpoint groups.

GET /v1/health

Liveness probe. Returns API status, catalog health, and database connectivity. No auth required.

GET /v1/models

List all available models. Supports filtering by category, provider, and full-text search. Auth optional.

GET /v1/models/{model_id}

Retrieve detailed info for a single model by its ID slug.

POST /v1/chat/completions

Send a message list to any LLM. Supports streaming (SSE), function calling, vision, and system prompts.

POST /v1/images/generations Async

Generate images from text prompts. Transparent async polling — BelugAPI returns URLs directly once generation completes.

POST /v1/videos/generations Async

Submit a video generation task. Returns a task_id immediately; poll the task endpoint to get the video URL.

GET /v1/videos/tasks/{task_id}

Poll video generation status. When status becomes completed, the response includes the downloadable video URL.

POST /v1/audio/speech

Convert text to speech (TTS). Streams binary audio in your chosen format (mp3, wav, flac…).

POST /v1/audio/transcriptions

Transcribe audio to text (STT). Send a multipart/form-data request with your audio file.


Quick example

Get up and running with a single API call.

from openai import OpenAI

client = OpenAI(
    api_key="bapi_your_key_here",
    base_url="https://api.belugapi.com/v1"
)

response = client.chat.completions.create(
    model="gpt-5.4",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "bapi_your_key_here",
  baseURL: "https://api.belugapi.com/v1",
});

const response = await client.chat.completions.create({
  model: "gpt-5.4",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
curl https://api.belugapi.com/v1/chat/completions \
  -H "Authorization: Bearer bapi_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Response format

All responses follow the OpenAI JSON schema. Errors always return a top-level error object with message, type, and optional code.

Error response
{
  "error": {
    "message": "The model 'foo' does not exist.",
    "type":    "invalid_request_error",
    "code":    "model_not_found",
    "param":   "model"
  }
}

SDKs & Libraries

Because BelugAPI is OpenAI-compatible, you can use any OpenAI SDK with a one-line change.

LanguageInstallConfig change
Python pip install openai Set base_url="https://api.belugapi.com/v1"
Node.js npm install openai Set baseURL: "https://api.belugapi.com/v1"
Go go get github.com/sashabaranov/go-openai Pass custom ClientConfig with BaseURL
REST Send requests directly to https://api.belugapi.com/v1