Skip to content
All guidesOpen

Docs / For renters

OpenAI SDK in Python and JavaScript

Use the official OpenAI libraries. Change the base URL and the key, nothing else.

Ballast has no SDK of its own. Use the official OpenAI libraries and change two things: the base URL and the key. Keep the key in an environment variable, never in source.

Terminalsh
export BALLAST_API_KEY=bl_your_key_here

Python

Terminalsh
pip install openai
hello.pypython
import os
from openai import OpenAI

client = OpenAI(base_url="https://ballast.outerscope.xyz/v1", api_key=os.environ["BALLAST_API_KEY"])

reply = client.chat.completions.create(
    model="qwen3-14b",
    messages=[{"role": "user", "content": "Explain a GPU in one sentence."}],
    max_tokens=200,
)
print(reply.choices[0].message.content)

JavaScript

Terminalsh
npm install openai
hello.mjsjs
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://ballast.outerscope.xyz/v1", apiKey: process.env.BALLAST_API_KEY });

const reply = await client.chat.completions.create({
  model: "qwen3-14b",
  messages: [{ role: "user", content: "Explain a GPU in one sentence." }],
  max_tokens: 200,
});
console.log(reply.choices[0].message.content);

What works

  • POST /v1/chat/completions, streaming or not, and GET /v1/models. Those are the two endpoints on the base URL.
  • Text messages with the system, user and assistant roles. The newer developer role is treated as system.
  • max_tokens (or max_completion_tokens), temperature, top_p, stop (up to 4), seed, presence_penalty and frequency_penalty.
  • stream_options.include_usage, so the last streamed chunk can carry token counts.

What does not

Tools and function calling, images, audio and files, n above 1, embeddings and the image endpoints are not offered. Ballast runs text chat on open models and nothing else, for now.

If a request carries a parameter Ballast cannot honour, it is refused with a 400 and the code unsupported_parameter. That is on purpose. You should never believe a feature worked when it was quietly dropped. See Errors.

Something here wrong or missing? Tell us on Support.