Skip to main content

Your first request

Base URL: https://api.oceantoken.ai. The API is OpenAI-compatible, so an OpenAI SDK needs only the base URL and your key. Claude models also answer on the Anthropic messages API.

Every sample on this page is a file we run against the service before publishing. Set OCEANTOKEN_API_KEY to your key and they run as-is.

# Chat completion with curl. Any OpenAI-compatible client works the same way:
# point it at the base URL and use your OceanToken key.
curl -sS "${OCEANTOKEN_BASE_URL:-https://api.oceantoken.ai}/v1/chat/completions" \
-H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5-mini",
"messages": [{"role": "user", "content": "Say hello in one short sentence."}]
}'

A successful response is the standard chat completion object: the answer under choices[0].message.content, and usage with the token counts you were billed for.

Stream the answer​

For anything a person is waiting on, stream. Tokens arrive as they are generated, and long answers do not run into the request timeout described in Limits.

# Streaming: tokens arrive as they are generated. Use this for anything a person
# is waiting on, and for long answers, which would otherwise hit the request timeout.
import os
from openai import OpenAI

client = OpenAI(
base_url=os.getenv("OCEANTOKEN_BASE_URL", "https://api.oceantoken.ai") + "/v1",
api_key=os.environ["OCEANTOKEN_API_KEY"],
)

with client.chat.completions.create(
model="openai/gpt-5-mini",
messages=[{"role": "user", "content": "Count from one to five, one number per line."}],
stream=True,
) as stream:
for chunk in stream:
delta = chunk.choices[0].delta.content if chunk.choices else None
if delta:
print(delta, end="", flush=True)
print()

Claude with the Anthropic SDK​

# pip install anthropic
# Claude models are served on /v1/messages. The Anthropic SDK works unchanged:
# give it the OceanToken base URL and your OceanToken key.
import os
import anthropic

client = anthropic.Anthropic(
base_url=os.getenv("OCEANTOKEN_BASE_URL", "https://api.oceantoken.ai"),
api_key=os.environ["OCEANTOKEN_API_KEY"],
)

message = client.messages.create(
model="anthropic/claude-haiku-4.5",
max_tokens=64,
messages=[{"role": "user", "content": "Say hello in one short sentence."}],
)
print(message.content[0].text)

See what you can call​

# The models your key can call, in the standard list format.
curl -sS "${OCEANTOKEN_BASE_URL:-https://api.oceantoken.ai}/v1/models" \
-H "Authorization: Bearer $OCEANTOKEN_API_KEY"

The list reflects your key: if your account is limited to certain models, only those appear. The full catalog with prices is on the Models page and in the console.

Next​

  • Pick a model on the Models page; the name in the table is the model value.
  • Every endpoint, including images, video, speech and embeddings, is on the API page.
  • Watch the request land in the console under Logs, with its cost and latency.