Examples

Explore practical OpenAI Responses and Anthropic Messages examples for integrating with Thesean.

Basic Message

import anthropic

client = anthropic.Anthropic(
    base_url="https://api.thesean.ai",
    api_key=THESEAN_API_KEY,
)

message = client.messages.create(
    model="ship-like/claude-opus-4-8",
    max_tokens=1024,
    system="You are a helpful assistant.",
    messages=[
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
)

print(message.content[0].text)

GPT with the Responses API

import openai

openai_client = openai.OpenAI(
    base_url="https://api.thesean.ai/v1",
    api_key=THESEAN_API_KEY,
)

response = openai_client.responses.create(
    model="ship-like/gpt-5.6-sol",
    input="Explain quantum computing in simple terms.",
)

print(response.output_text)

Streaming

with client.messages.stream(
    model="ship-like/claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a short story."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Tool Use

response = client.messages.create(
    model="ship-like/claude-opus-4-8",
    max_tokens=1024,
    tools=[
        {
            "name": "get_weather",
            "description": "Get the current weather in a location",
            "input_schema": {
                "type": "object",
                "properties": {
                    "location": {"type": "string"},
                },
                "required": ["location"],
            },
        }
    ],
    messages=[
        {"role": "user", "content": "What's the weather like in Boston?"}
    ],
)

for item in response.content:
    if item.type == "tool_use":
        print(item.name, item.input)

Choosing the API

Use ship-like/gpt-5.6-sol with the Responses API. Use ship-like/claude-opus-4-8, ship-like/claude-sonnet-5, or ship-like/claude-haiku-4-5 with the Messages API. The examples above demonstrate both API paths.

Retry Logic

from tenacity import retry, stop_after_attempt, wait_exponential

@retry(
    stop=stop_after_attempt(3),
    wait=wait_exponential(multiplier=1, min=4, max=10),
)
def send_message(messages):
    return client.messages.create(
        model="ship-like/claude-opus-4-8",
        max_tokens=1024,
        messages=messages,
    )

Next Steps

Anthropic SDK Integration

Learn how to configure and use the Anthropic SDK.

Read more

API Endpoints Reference

Review Responses and Messages API parameters and examples.

Read more