Skip to main content

Text Generation

Drop-in OpenAI and Anthropic compatible

Chat and text completion via OpenAI-compatible /v1/chat/completions and Anthropic-compatible /v1/messages — point your existing SDK at the gateway and pick any model.

Text generation is the gateway's core surface. Both API formats route through the same multi-provider engine, so you can call a Claude model in OpenAI format or a GPT model in Anthropic format — the gateway translates and bills per token from your credit balance.

Generating text

POST /v1/chat/completions (OpenAI format) · POST /v1/messages (Anthropic format)

Authentication is the same as every other gateway endpoint — a Bankr API key (bk_...) via X-API-Key or Authorization: Bearer. Generate keys at bankr.bot/api-keys.

curl -X POST https://llm.bankr.bot/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: bk_YOUR_API_KEY" \
-d '{
"model": "claude-opus-4.8",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}'

Using the OpenAI SDK, only the base URL and key change:

from openai import OpenAI

client = OpenAI(base_url="https://llm.bankr.bot/v1", api_key="bk_YOUR_API_KEY")

completion = client.chat.completions.create(
model="claude-opus-4.8",
messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)

Both formats are documented in full — including request/response fields and the Anthropic /v1/messages shape — in the API Reference. For framework integrations (Vercel AI SDK, LangChain, etc.), see Apps.

Streaming

Set "stream": true to receive server-sent events as the completion is generated; the stream shape matches the provider format you called (OpenAI chat.completion.chunk or Anthropic message events). See Streaming.

Parameters

The body is forwarded to the provider, so any parameter it accepts works. The most common:

ParameterDescription
modelRequired. Any text model from /v1/models.
messagesRequired. The conversation, in the format you're calling.
temperatureSampling temperature.
max_tokensMax tokens to generate (max_tokens on /v1/messages is required).
streamtrue for server-sent events.

Supported models

Text generation runs on any model that produces text output — the large majority of the catalog. The source of truth is the /v1/models endpoint: a text model reports "output_modalities": ["text"] (or omits the field, which defaults to text).

bankr llm models    # or GET /v1/models

See Supported Models for the full catalog, and Private Inference to run select models inside a TEE.

Pricing

Text generation bills per token from your LLM credit balance — separate input and output rates per model (some also price cached tokens). Exact per-model rates are on the Supported Models page and in /v1/models under pricing. See credit management to top up.

Next steps