Borg Gateway Quickstart
On this page
Before you start
The gateway URL and key come from Borg Settings, and this API is a developer preview. Borg provides an OpenAI-compatible chat completions interface. Do not copy a gateway address from an example or share your key.
These examples follow the standard OpenAI chat-completions request/response shape; they have not been run against the live Borg gateway, so confirm the response against your own account before relying on it in production code.
In each example, set BASE_URL to the base URL from Borg Settings. Set BORG_API_KEY to the key from the same page. Keep the base URL as provided, including any path it contains. The request adds /chat/completions.
curl
export BASE_URL="<base URL from Borg Settings>"
export BORG_API_KEY="<key from Borg Settings>"
curl "$BASE_URL/chat/completions" \
-H "Authorization: Bearer $BORG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'The response follows the chat completions shape. Read the assistant reply from the first choice's message content. The model value is a Borg lane ID, not a promise that every request uses a particular provider implementation beyond that lane.
Python
Install the OpenAI Python package in your environment, then run:
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["BASE_URL"],
api_key=os.environ["BORG_API_KEY"],
)
response = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(response.choices[0].message.content)Set BASE_URL and BORG_API_KEY in your shell before starting Python. The SDK sends the request to the base URL you supplied.
Node.js
Install the OpenAI JavaScript package, then run:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: process.env.BASE_URL,
apiKey: process.env.BORG_API_KEY,
});
const response = await client.chat.completions.create({
model: "claude-sonnet-5-5",
messages: [{ role: "user", content: "Say hello in one sentence." }],
});
console.log(response.choices[0].message.content);If the request fails
Check that the base URL and key match the values in Borg Settings, and that the environment variables are set in the process running the code. Check the JSON spelling and use claude-sonnet-5-5 as the model. Never place the key in client-side code, a public repository, or a shared example.
Frequently asked questions
Where do I get the key and base URL?
Find both in Borg Settings. Keep the key private.
Which model does this example use?
It uses the Borg lane ID claude-sonnet-5-5.
Is the request OpenAI-compatible?
Yes. The example uses the chat completions format.