Skip to navigation

What changes when I use BeatAPI with the OpenAI SDK?

Connecting the OpenAI SDK to BeatAPI requires changing only three settings: the API key, base_url (https://direct.beatapi.io/v1), and the exact enabled model ID. Existing Chat Completions (messages) and Responses (input) code structures remain unchanged.

Minimal SDK configuration

Configure the server-side SDK client with BEATAPI_API_KEY, point base_url to https://direct.beatapi.io/v1 (which avoids Cloudflare’s 100-second limit on long text calls; https://api.beatapi.io/v1 serves as fallback), and choose an enabled model ID such as gpt-6-luna.

import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["BEATAPI_API_KEY"],
base_url="https://direct.beatapi.io/v1",
)
completion = client.chat.completions.create(
model="gpt-6-luna",
messages=[{"role": "user", "content": "Reply with OK."}],
)
print(completion.model, completion.choices[0].message.content)

Verification and rollout steps

  1. Check enabled models: Call GET https://api.beatapi.io/v1/models with Authorization: Bearer <BEATAPI_API_KEY> when unsure which model IDs the key can reach.
  2. Match protocol shape: Keep messages for Chat Completions (POST /v1/chat/completions) and input for Responses (POST /v1/responses).
  3. Enable options incrementally: After one short non-streaming request returns the expected model and content, turn streaming and structured output options back on one at a time. Keep permanent keys on trusted servers rather than client bundles.

GPT reference

Before sending a paid request, inspect the model contracts for free: model:gpt-6-luna, model:gpt-image-2.5-flare-std.

Back to AI Models questions.