API reference
Call models with an API key, and read account credit with a separate system access token.
Create a key in the console, keep it on your server, then send OpenAI-compatible or Anthropic-compatible requests. Account endpoints use a different credential.
If you only need a first request, start at Quickstart. Public USD prices are on Pricing and in pricing.usd.json. Failed calls are covered in Errors.
Two credentials
Do not mix these. Model calls use an API key. Account endpoints use a system access token.
| Credential | Looks like | Used for | Where to create |
|---|---|---|---|
| API key | sk-... | Model calls (/v1/...) | API keys |
| System access token | A random string that does not start with sk- | Account endpoints (/api/...) | Account settings → Security settings |
Creating an API key:
- Open API keys.
- Create a key and copy the full
sk-...value at once. - Store it as an environment variable on your server. Do not put it in browser code or a public repository.
Creating a system access token:
- Open Account settings.
- Open Security settings.
- Generate a system access token and save it immediately.
Regenerating the system access token replaces the previous one. The old value stops working.
Your user ID is on the Account settings page, labeled ID. Account endpoints need that ID in the New-Api-User header.
Base URLs
| Client | Base URL |
|---|---|
| OpenAI-compatible SDKs and HTTP | https://global.beefapi.com/v1 |
| Anthropic SDK and Claude Code | https://global.beefapi.com |
| Account API | https://global.beefapi.com/api |
Point the Anthropic SDK at the host root. It appends /v1/messages itself. OpenAI-compatible clients need /v1 on the base URL.
Authentication
API key
Use this for every model request:
Authorization: Bearer sk-...Anthropic-compatible calls also accept the Anthropic header:
x-api-key: sk-...
anthropic-version: 2023-06-01System access token
Use this only for account endpoints:
Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN
New-Api-User: YOUR_USER_IDNew-Api-User must match the user ID that owns the system access token. Both headers are required.
OpenAI-compatible calls
Base URL: https://global.beefapi.com/v1
| Method | Path | Use |
|---|---|---|
POST | /v1/chat/completions | Chat Completions |
POST | /v1/responses | Responses API |
GET | /v1/models | Model catalog for your key |
Prepaid USD credit pays for each completed model request. Usage appears on the Usage page.
Chat Completions
curl https://global.beefapi.com/v1/chat/completions \
-H "Authorization: Bearer $BEEFAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"messages": [
{"role": "user", "content": "Hello"}
]
}'The request and response match OpenAI Chat Completions. Replace gpt-5.6-sol with a model ID that your key can call.
Responses API
Send model and input. This example saves the complete response:
curl --fail-with-body https://global.beefapi.com/v1/responses \
-H "Authorization: Bearer $BEEFAPI_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.6-sol","input":"Explain what an API gateway does in one sentence."}' \
-o response.jsonRead text from message items in output; other items can represent reasoning or tool calls:
import json
from pathlib import Path
response = json.loads(Path("response.json").read_text())
for item in response.get("output", []):
if item.get("type") == "message":
for part in item.get("content", []):
if part.get("type") == "output_text":
print(part["text"])Streaming
Set "stream": true for Server-Sent Events (text/event-stream). Use curl's --no-buffer option to see events as they arrive:
curl --fail-with-body --no-buffer https://global.beefapi.com/v1/chat/completions \
-H "Authorization: Bearer $BEEFAPI_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.6-sol","messages":[{"role":"user","content":"Say hello."}],"stream":true}'Chat Completions streams carry JSON in data: events and finish with data: [DONE]. Read text from choices[].delta.content; not every event contains text. An HTTP chunk can contain several events or part of one event, so use an SSE parser or SDK instead of parsing each network chunk as JSON.
For Responses, use the same streaming flag on /v1/responses. Read response.output_text.delta events and wait for response.completed; handle error, failed, and incomplete outcomes. Anthropic Messages uses its own event types and ends with message_stop. Do not treat these three stream formats as interchangeable.
Python SDK example (after python3 -m pip install openai):
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["BEEFAPI_KEY"],
base_url="https://global.beefapi.com/v1")
with client.responses.stream(model="gpt-5.6-sol", input="Say hello.") as stream:
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
response = stream.get_final_response()
print("\nStatus:", response.status)A stream that disconnects after producing output may already have incurred usage. Check Usage before retrying; see Errors.
Images and videos
| Method | Path | Guide |
|---|---|---|
| POST | /v1/images/generations | Generate images |
| POST | /v1/images/edits | Edit images |
| POST | /v1/videos | Create a video task |
| GET | /v1/videos/{id} | Poll a video task. |
| GET | /v1/videos/{id}/content | Download a completed video. |
Images return image data; videos return a task ID first. Neither follows the text streaming workflow above. Optional image-job endpoints and their availability limits are covered in Images.
Download the OpenAPI document for machine-readable request and response schemas.
List models
curl https://global.beefapi.com/v1/models \
-H "Authorization: Bearer $BEEFAPI_KEY"The JSON is an OpenAI-style list (object: list plus a data array of model objects). With a key, the list reflects the catalog for that key; a listed model can still be temporarily unavailable. Without a key, GET /v1/models still returns 200 with the public catalog.
Use the exact id string from that list. Public prices for the catalog are on Pricing. Your signed-in account decides which of those IDs you can call.
Anthropic-compatible calls
Set the Anthropic SDK or Claude Code base URL to https://global.beefapi.com. Direct HTTP uses the full path:
curl https://global.beefapi.com/v1/messages \
-H "x-api-key: $BEEFAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 512,
"messages": [
{"role": "user", "content": "Hello"}
]
}'Use an API key (sk-...) in x-api-key. Include anthropic-version. max_tokens is required by the Anthropic Messages API. Pick a model ID from GET /v1/models for your key.
Streaming uses the same "stream": true field as the OpenAI-compatible endpoints.
Account endpoints
Account endpoints use https://global.beefapi.com/api. They use the system access token, not the API key.
Check the signed-in account, including remaining credit:
curl https://global.beefapi.com/api/user/self \
-H "Authorization: Bearer $BEEFAPI_ACCESS_TOKEN" \
-H "New-Api-User: $BEEFAPI_USER_ID"A successful body looks like { "success": true, "data": { ... } }. Useful fields:
| Field | Meaning |
|---|---|
data.id | User ID (the value for New-Api-User) |
data.quota | Remaining credit (not a USD amount) |
data.used_quota | Historical consumption (same units as quota) |
data.request_count | Request count |
The console shows the USD amount. Billing is the place to add prepaid USD credit. Do not convert quota with a hardcoded rate in your client.
Without a system access token, GET /api/user/self returns 401 with { "success": false, "message": "..." }. A failed account call looks different from a failed model request. See Errors.
This endpoint reports the account, not a single sk-... key.
Common mistakes
- Using the system access token as
Authorization: Beareron/v1/chat/completionsor/v1/messages. - Using an
sk-...API key on/api/user/self. - Omitting
New-Api-Useron account calls. - Pointing an OpenAI client at
https://global.beefapi.comwithout/v1. - Pointing Claude Code or the Anthropic SDK at
https://global.beefapi.com/v1instead of the host root. - Sending a model ID that is not in
GET /v1/modelsfor that key. That is a404model_not_found. See Errors.