Skip to content
SDKs

SDKs

Any OpenAI or Anthropic SDK works out of the box.

Shannon speaks the OpenAI and the Anthropic wire formats, so you use the official SDKs of both as they are. You change three values in the client: the base URL, the API key and the model id. The rest of your code stays the same.

What to set

Setting OpenAI SDKs Anthropic SDKs
Base URL https://api.shannon-ai.com/v1 https://api.shannon-ai.com
API key Your Shannon key. The SDK sends it as Authorization: Bearer. Your Shannon key. The SDK sends it as x-api-key.
Model A published model id, for example shannon-3. A published model id, for example shannon-1.6-lite.
Endpoints it reaches /v1/chat/completions, /v1/responses, /v1/models /v1/messages, /v1/messages/count_tokens
Environment variables OPENAI_API_KEY and OPENAI_BASE_URL, read by the Python and JavaScript SDKs when you pass no value. ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL, read by the Python and TypeScript SDKs when you pass no value.

The two base URLs differ by /v1: an OpenAI SDK adds /chat/completions to its base URL, an Anthropic SDK adds /v1/messages. A model name that Shannon does not publish is answered with 400 and unknown model. Models & pricing

Your key is on the Keys & usage page. Keys & usage

OpenAI SDKs

The official OpenAI SDKs call POST /v1/chat/completions and POST /v1/responses. Each sample sends one user message and prints the answer.

# pip install openai
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.shannon-ai.com/v1",
)

response = client.chat.completions.create(
    model="shannon-3",
    messages=[{"role": "user", "content": "Hello, Shannon!"}],
)
print(response.choices[0].message.content)
Language Install Base URL option Source
Python pip install openai base_url openai/openai-python
JavaScript / TypeScript npm install openai baseURL openai/openai-node
Go go get github.com/openai/openai-go/v3 option.WithBaseURL openai/openai-go
Java com.openai:openai-java baseUrl openai/openai-java
.NET dotnet add package OpenAI OpenAIClientOptions.Endpoint openai/openai-dotnet

Every field of the two endpoints is described on their own pages. Chat Completions Responses API

Anthropic SDKs

The official Anthropic SDKs call POST /v1/messages. They require max_tokens on every call, so the samples use shannon-1.6-lite, which applies it. Each sample prints the text blocks of the answer.

# pip install anthropic
import anthropic

client = anthropic.Anthropic(
    api_key="YOUR_API_KEY",
    base_url="https://api.shannon-ai.com",
)

message = client.messages.create(
    model="shannon-1.6-lite",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Shannon!"}],
)
for block in message.content:
    if block.type == "text":
        print(block.text)
Language Install Base URL option Source
Python pip install anthropic base_url anthropics/anthropic-sdk-python
TypeScript npm install @anthropic-ai/sdk baseURL anthropics/anthropic-sdk-typescript
Go go get github.com/anthropics/anthropic-sdk-go option.WithBaseURL anthropics/anthropic-sdk-go
Java com.anthropic:anthropic-java baseUrl anthropics/anthropic-sdk-java

The Messages format and its differences are on the Anthropic compatibility page. Anthropic Format

What the SDKs can rely on

  • A request field the API does not use is accepted. A field the API knows, sent with the wrong type, is answered with 422.
  • The version and beta headers the SDKs add (anthropic-version, anthropic-beta, openai-beta) are accepted. None of them is required.
  • The model of a reply is the published id, so you can send it back as it is.
  • On /v1/messages a reply can start with a thinking block. Read the blocks of type text instead of taking the first block.
  • Streaming works through the SDK's own stream helpers. Usage arrives at the end of every stream.
  • Every reply carries an x-request-id header. Send your own x-request-id and the same value comes back.

Community SDKs

Clients written for the OpenAI API by other authors work the same way: give the client the base URL with /v1, your key and a Shannon model id. These are maintained by their authors, not by Shannon.

Language Install Client
Go go get github.com/sashabaranov/go-openai sashabaranov/go-openai
Ruby gem install ruby-openai alexrudall/ruby-openai
PHP composer require openai-php/client openai-php/client
Rust cargo add async-openai 64bit/async-openai

Without an SDK

You do not need an SDK. Any HTTP client that can send JSON works:

  • POST with a JSON body and the header Content-Type: application/json. Without it the request is answered with 415.
  • Your key in Authorization: Bearer <key> or in x-api-key: <key>. Both work on every endpoint.
  • A body of up to 32 MiB.
  • With "stream": true the reply is a server-sent event stream (text/event-stream). Read it line by line and do not buffer it.
  • An error is a JSON body with error.type and error.message, next to the HTTP status.
curl https://api.shannon-ai.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "shannon-3",
    "messages": [{"role": "user", "content": "Hello, Shannon!"}]
  }'

For the events of a stream and the error types, see: Streaming Error Handling