Skip to content

Getting started

Quickstart

Use the official OpenAI SDKs you already know. Point them at your endpoint, authenticate with your key, choose a model — the rest of your code stays the same.

  • An API key. Keys are issued during onboarding and managed in the console — see Authentication.
  • Python 3.8+ or Node.js 18+, or any HTTP client that can send JSON over HTTPS.
  • A model your plan includes. The examples use qwen3-30b-a3b, bge-m3 and whisper-large-v3-turbo; replace them with any ID from Models.

There is no proprietary SDK to learn. Install the official OpenAI library for your language.

pip install --upgrade openai

Store the key and base URL as environment variables rather than in source code. The examples on these pages read LIRUX_API_KEY and LIRUX_BASE_URL.

.env
LIRUX_API_KEY=sk-...           # from your console or onboarding email
LIRUX_BASE_URL=https://api.lirux.ai/v1
shell
export LIRUX_API_KEY="sk-..."
export LIRUX_BASE_URL="https://api.lirux.ai/v1"

Create the client once and reuse it across requests:

from openai import OpenAI
import os

client = OpenAI(
    base_url=os.environ["LIRUX_BASE_URL"],
    api_key=os.environ["LIRUX_API_KEY"],
)

Keep keys on the server

Never ship an API key in a browser bundle or mobile app. Call the API from your backend and expose only your own endpoints to clients. Why and how →

A chat completion takes a model ID and a list of messages, and returns the assistant's reply together with token usage.

from openai import OpenAI
import os

client = OpenAI(
    base_url="https://api.lirux.ai/v1",
    api_key=os.environ["LIRUX_API_KEY"],
)

response = client.chat.completions.create(
    model="qwen3-30b-a3b",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Summarise our Q3 support tickets."},
    ],
)

print(response.choices[0].message.content)

The response follows the OpenAI chat completion shape:

response.json
{
  "id": "chatcmpl-9b2e4c1a",
  "object": "chat.completion",
  "created": 1759312800,
  "model": "qwen3-30b-a3b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The customer reports failed invoice exports since the last update. A workaround was shared; a fix is scheduled."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 41, "completion_tokens": 27, "total_tokens": 68 }
}

Getting a 401? Check that the key is set in the environment your code runs in. Getting a 403 with model_not_in_plan? The model is not enabled for your key — see Errors.

Set stream to true to receive tokens as they are generated, as server-sent events. The SDKs expose the stream as an iterator.

stream = client.chat.completions.create(
    model="qwen3-30b-a3b",
    messages=[{"role": "user", "content": "Write a release note."}],
    stream=True,
)

for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

On the wire, each event is a data: line containing a chat.completion.chunk. The stream ends with data: [DONE].

text/event-stream
data: {"id":"chatcmpl-7f1c","object":"chat.completion.chunk","created":1759312800,"model":"qwen3-30b-a3b","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-7f1c","object":"chat.completion.chunk","created":1759312800,"model":"qwen3-30b-a3b","choices":[{"index":0,"delta":{"content":"Release"},"finish_reason":null}]}

data: {"id":"chatcmpl-7f1c","object":"chat.completion.chunk","created":1759312800,"model":"qwen3-30b-a3b","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Embeddings turn text into vectors for semantic search and RAG retrieval. Pass a string or an array of strings; vectors are returned in input order. bge-m3 is multilingual, so German and English text land in the same vector space.

result = client.embeddings.create(
    model="bge-m3",
    input=["Wartungsintervall Hydraulikpumpe", "Pump maintenance interval"],
)

vector = result.data[0].embedding

The transcription endpoint is Whisper-compatible and accepts a multipart file upload. Set language when you know it — it avoids misdetection on short clips.

with open("call-2026-10-01.mp3", "rb") as audio:
    transcript = client.audio.transcriptions.create(
        model="whisper-large-v3-turbo",
        file=audio,
    )

print(transcript.text)

GET /v1/models returns the model IDs your key can call. Use it as a health check during deployment and to validate configuration at start-up.

curl https://api.lirux.ai/v1/models \
  -H "Authorization: Bearer $LIRUX_API_KEY"
response.json
{
  "object": "list",
  "data": [
    {
      "id": "qwen3-30b-a3b",
      "object": "model",
      "created": 1759276800,
      "owned_by": "lirux"
    },
    {
      "id": "qwen3-8b",
      "object": "model",
      "created": 1759276800,
      "owned_by": "lirux"
    },
    {
      "id": "bge-m3",
      "object": "model",
      "created": 1759276800,
      "owned_by": "lirux"
    }
  ]
}