---
title: "Call Bearly's zero-retention API"
description: "Make a first call to Claude or GPT through Bearly's API with the OpenAI or Anthropic SDK, a Bearly API key, and a new base URL, then list models and read errors. Every API request goes to a zero-retention route."
canonical: "https://bearly.ai/docs/api-quickstart/"
markdown: "https://bearly.ai/docs/api-quickstart.md"
---

# Call Bearly's zero-retention API

HTML: [https://bearly.ai/docs/api-quickstart/](https://bearly.ai/docs/api-quickstart/)

> Make a first call to Claude or GPT through Bearly's API with the OpenAI or Anthropic SDK, a Bearly API key, and a new base URL, then list models and read errors. Every API request goes to a zero-retention route.

Call Claude, GPT, and Grok from your own code with the official OpenAI or Anthropic SDK and a Bearly API key. Every API request goes to a zero-retention route: the model provider doesn't keep your prompt or the model's response after processing them. This page gets you to a first answer; [Use the Bearly API](https://bearly.ai/docs/api-access.md) is the full reference.

## Before you start

1. **Create an API key.** In Bearly, open your account menu and select **Developers**. Under **API Keys**, select **Create API Key** (or **New Key** if you already have one), add a note such as "My script", select **Create**, and copy the key. If **Developers** or **API Keys** is missing, your team administrator has turned off API access.
2. **Store it in an environment variable.** The examples read `BEARLY_API_KEY`:

    ```bash
    export BEARLY_API_KEY="paste-your-key-here"
    ```

3. **Install the SDK you'll use:** `pip install openai anthropic` or `npm install openai @anthropic-ai/sdk`.

You don't need an OpenAI or Anthropic key. Requests spend your Bearly plan's allowance and credits, the same as chat.

## Base URLs

| SDK | Base URL | Models |
| --- | --- | --- |
| OpenAI (Responses and Chat Completions) | `https://api.bearly.ai/v1` | GPT, Grok, Bearly's own models, and the others that list these APIs |
| Anthropic (Messages) | `https://api.bearly.ai` | Claude |

If your code already reads `OPENAI_BASE_URL` and `OPENAI_API_KEY`, or `ANTHROPIC_BASE_URL` and `ANTHROPIC_API_KEY`, you can set those to the base URL and your Bearly key instead of changing code.

## Find a model

Listing models doesn't need a key:

```bash
curl https://api.bearly.ai/v1/models
```

Each model lists the APIs it works with under `endpoints`: `/v1/responses`, `/v1/chat/completions`, or `/v1/messages`. Use a model only with an API it lists, and copy its `id` exactly. To get the list in Anthropic's format, which includes only Claude models, add the version header:

```bash
curl https://api.bearly.ai/v1/models -H "anthropic-version: 2023-06-01"
```

From code, `client.models.list()` returns the same lists in either SDK. Models can be added or removed, so check the list rather than hard-coding one forever.

## Call GPT with the OpenAI SDK


**Python**

```python
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.bearly.ai/v1",
    api_key=os.environ["BEARLY_API_KEY"],
)

response = client.responses.create(
    model="gpt-6.1-sol",
    input="In one sentence, what is zero data retention?",
    max_output_tokens=1000,
)
print(response.output_text)
```


**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
    baseURL: "https://api.bearly.ai/v1",
    apiKey: process.env.BEARLY_API_KEY,
});

const response = await client.responses.create({
    model: "gpt-6.1-sol",
    input: "In one sentence, what is zero data retention?",
    max_output_tokens: 1000,
});
console.log(response.output_text);
```




`max_output_tokens` caps the reply, including the model's reasoning, so a test can't run up a large bill. The same client works with `chat.completions.create` for models that list `/v1/chat/completions`.

## Call Claude with the Anthropic SDK


**Python**

```python
import os

from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.bearly.ai",
    api_key=os.environ["BEARLY_API_KEY"],
)

message = client.messages.create(
    model="claude-haiku-5-5",
    max_tokens=200,
    messages=[{"role": "user", "content": "In one sentence, what is zero data retention?"}],
)
print(next(block.text for block in message.content if block.type == "text"))
```


**TypeScript**

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

const client = new Anthropic({
    baseURL: "https://api.bearly.ai",
    apiKey: process.env.BEARLY_API_KEY,
});

const message = await client.messages.create({
    model: "claude-haiku-5-5",
    max_tokens: 200,
    messages: [{ role: "user", content: "In one sentence, what is zero data retention?" }],
});
console.log(message.content.find((block) => block.type === "text")?.text);
```




Claude models work only through the Anthropic SDK, and GPT and Grok only through the OpenAI SDK. If your code stops reading a stream early, the model still finishes the response and the full response is billed.

## Errors

Errors come back in the SDK's own format, so the SDK raises its usual exception, such as `AuthenticationError`. A wrong key looks like this:


**OpenAI SDK**

```json
{"error": {"message": "invalid or expired API key", "type": "invalid_request_error", "param": null, "code": null}}
```


**Anthropic SDK**

```json
{"type": "error", "error": {"type": "authentication_error", "message": "invalid or expired API key"}}
```




| Status | Meaning | What to do |
| --- | --- | --- |
| `401` | The key is missing, wrong, or deleted. | Check `BEARLY_API_KEY`, or create a new key under **API Keys**. |
| `402` | The model needs a different plan, or your allowance or credits can't cover the request. | Add credits, change plans, or pick another model. |
| `403` | Your team's policy turns off API access or doesn't allow this model. | Ask your team administrator, or pick an allowed model. |
| `404` `model_not_found` | The model ID is wrong, the model doesn't support the API you called, or it's no longer offered. | Check the [model list](#find-a-model) and switch SDK if needed. |
| `429` | Your account already has 10 API requests running. | Wait for one to finish. Both SDKs retry twice by default; keep retries and parallel jobs bounded. |

The [full reference](https://bearly.ai/docs/api-access.md#errors) covers the rest.

## What isn't supported

- **Stored responses.** Responses requests always run with storage off, so `previous_response_id`, background mode, and retrieving a past response aren't available. Send the conversation history with each request.
- **Provider-hosted tools.** Built-in web search, file search, code execution, and provider-hosted MCP servers return a `400` error.
- **Gemini.** Gemini models aren't available through the API.
- **Other endpoints.** Embeddings, images, audio, fine-tuning, and token counting aren't available.

## Related

- [Use the Bearly API](https://bearly.ai/docs/api-access.md): the full reference, with per-model tool-calling limits, team controls, and every error.
- [Use zero-data-retention models](https://bearly.ai/docs/zero-data-retention.md): what the zero-data-retention label means.

## Continue through the documentation

- [Documentation index](https://bearly.ai/docs.md): Browse every Bearly guide.
- [Previous: Delete your Bearly account](https://bearly.ai/docs/account/delete-account.md)
- [Next: Use the Bearly API](https://bearly.ai/docs/api-access.md)
- [Related: Use zero-data-retention models](https://bearly.ai/docs/zero-data-retention.md)
