Skip to content

Quick start

Get a key, send a chat completion and read the reply.

A first chat completion in three steps, then a first speech file.

Get a key

The owner of albastov.com issues abk_ keys to an albastov.com account, with scopes: llm for language models, media:generate for speech. The key is shown once, at creation. Store the key in an environment variable:

Shell
export ALBASTOV_API_KEY=abk_...

Scopes and key handling: Authentication.

Send a request

A chat completion with qwen3.8-27b, through curl, the OpenAI Python SDK or fetch.

curl

curl https://api.albastov.com/v1/chat/completions \
  -H "Authorization: Bearer $ALBASTOV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-27b",
    "messages": [{"role": "user", "content": "Say hello in five words."}],
    "chat_template_kwargs": {"enable_thinking": false},
    "max_tokens": 50
  }'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.albastov.com/v1", api_key=os.environ["ALBASTOV_API_KEY"])
reply = client.chat.completions.create(
    model="qwen3.8-27b",
    messages=[{"role": "user", "content": "Say hello in five words."}],
    extra_body={"chat_template_kwargs": {"enable_thinking": False}},
    max_tokens=50,
)
print(reply.choices[0].message.content)

JavaScript

const res = await fetch("https://api.albastov.com/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ALBASTOV_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "qwen3.8-27b",
    messages: [{ role: "user", content: "Say hello in five words." }],
    chat_template_kwargs: { enable_thinking: false },
    max_tokens: 50,
  }),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const reply = await res.json();
console.log(reply.choices[0].message.content);

Read the reply

The reply is JSON. The answer is choices[0].message.content; usage counts the tokens.

Response
{
  "id": "chatcmpl-b50af0eb9c5d02d9",
  "object": "chat.completion",
  "created": 1793305215,
  "model": "qwen3.8-27b",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "Hello there, my friend.", "reasoning": null},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 7,
    "total_tokens": 25,
    "prompt_tokens_details": {"cached_tokens": 0},
    "completion_tokens_details": {"reasoning_tokens": 0}
  }
}

A request for a model that is not loaded returns 503 model_loading with Retry-After: Rate limits.

Make speech

A key with media:generate turns text into an MP3 file with kokoro and the built-in voice af_heart.

curl

curl https://api.albastov.com/v1/audio/speech \
  -H "Authorization: Bearer $ALBASTOV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "kokoro", "voice": "af_heart", "input": "The river bends past the old mill, where a narrow footbridge crosses to the orchard on the far bank, and the path climbs gently into the hills."}' \
  --output speech.mp3

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.albastov.com/v1", api_key=os.environ["ALBASTOV_API_KEY"])
with client.audio.speech.with_streaming_response.create(
    model="kokoro",
    voice="af_heart",
    input="The river bends past the old mill, where a narrow footbridge crosses to the orchard on the far bank, and the path climbs gently into the hills.",
) as res:
    res.stream_to_file("speech.mp3")

JavaScript

import { writeFile } from "node:fs/promises";

const res = await fetch("https://api.albastov.com/v1/audio/speech", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ALBASTOV_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "kokoro",
    voice: "af_heart",
    input: "The river bends past the old mill, where a narrow footbridge crosses to the orchard on the far bank, and the path climbs gently into the hills.",
  }),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
await writeFile("speech.mp3", Buffer.from(await res.arrayBuffer()));

The response body is the audio file, Content-Type: audio/mpeg.

Guides

TaskGuide
Chat, streaming, tools and thinkingLanguage models
Speech in a built-in or saved voiceText to speech
A voice from a short clipVoice cloning
Transcripts from audioSpeech to text
Every route, parameter and errorChat completions reference