# SDKs

> The API speaks Anthropic Messages and OpenAI Chat Completions, so official SDKs work as-is.

Source: https://docs.strokes.ink/get-started/sdks

There is no Strokes SDK to install: use Anthropic's, with two settings changed — the **API key** and the **base URL**.

<Tabs items={["TypeScript","Python","Environment variables"]}>
<Tab value="TypeScript">
```bash
npm install @anthropic-ai/sdk
```

```ts
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.STROKES_API_KEY,
  baseURL: "https://api.strokes.ink",
});

const message = await client.messages.create({
  model: "swim-1.0",
  max_tokens: 32000,
  messages: [{ role: "user", content: "Hello" }],
});

for (const block of message.content) {
  if (block.type === "text") console.log(block.text);
}
```
</Tab>

<Tab value="Python">
```bash
pip install anthropic
```

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["STROKES_API_KEY"],
    base_url="https://api.strokes.ink",
)

message = client.messages.create(
    model="swim-1.0",
    max_tokens=32000,
    messages=[{"role": "user", "content": "Hello"}],
)
for block in message.content:
    if block.type == "text":
        print(block.text)
```
</Tab>

<Tab value="Environment variables">
The Anthropic SDKs also read their settings from the environment, so existing code can move to Strokes without a code change:

```bash
export ANTHROPIC_API_KEY="$STROKES_API_KEY"
export ANTHROPIC_BASE_URL="https://api.strokes.ink"
```

Then set `model` to `swim-1.0` in your requests.
</Tab>
</Tabs>

Without an explicit `apiKey` / `api_key`, the SDKs read `ANTHROPIC_API_KEY` — so pass `STROKES_API_KEY` in as above, or set the environment variables of the third tab.

## OpenAI SDKs

Code written for OpenAI works too, through [`/v1/chat/completions`](/api/chat-completions). Point the OpenAI SDK at `https://api.strokes.ink/v1` (this same `/v1` base URL also works with the Anthropic SDKs):

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.STROKES_API_KEY,
  baseURL: "https://api.strokes.ink/v1",
});

const completion = await client.chat.completions.create({
  model: "swim-1.0",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(completion.choices[0].message.content);
```

`chat.completions.create` (streamed or not, with function tools, web search and the model's reasoning as `reasoning_content`) and `models.list` work.

## Other languages

Any Anthropic SDK or HTTP client works the same way: send JSON to `https://api.strokes.ink/v1/messages` with the key in `x-api-key`. Headers the SDKs add, such as `anthropic-version`, are accepted and ignored.

The Anthropic SDKs require `max_tokens`; send `32000`, the model's maximum, which is what the API uses when the field is left out. The OpenAI SDKs and plain HTTP need none.

## What's supported

The SDK's `messages.create` and `messages.stream`, and `models.list` and `models.retrieve`, with:

- text and image content, system prompts, `stop_sequences`, `temperature` and `top_p`;
- [tools](/guides/tool-use), with `tool_choice`;
- [web search](/guides/web-search), on by default, and the `web_search` switch;
- [modes](/guides/modes), with `mode`;
- [strokes](/guides/strokes) personalization and voice profiles, with `stroke_id` or `stroke-id`;
- the reasoning level, `output_config.effort`, and the reasoning itself with `thinking`.

Not supported: `document` blocks, server tools other than `web_search_20250305` and `web_fetch_20250910`, `top_k`, `container`, `mcp_servers` and citations. See [Create a message](/api/messages) for every field.
