> For the complete documentation index, see [llms.txt](https://docs.blockbrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockbrain.ai/for-admins/llm-api.md).

# LLM API

Call the AI models of your organization directly, from your own code or from tools such as coding assistants. The LLM API speaks the formats of OpenAI, Anthropic and Google Gemini, so most existing SDKs and tools work by changing the base URL and the key.

{% hint style="info" %}
The LLM API must be enabled for your organization. If it is not, requests answer `403` with `llm_api_not_enabled`. Contact Blockbrain to enable it.
{% endhint %}

#### Base URL

| Hosting      | Base URL                                     |
| ------------ | -------------------------------------------- |
| Blockbrain   | `https://api.theblockbrain.ai/genai/v1`      |
| STACKIT (EU) | `https://api.eu-1.theblockbrain.ai/genai/v1` |

#### Authentication

Use a personal access token from [API Access](https://docs.blockbrain.ai/for-users/api-access.md). Send it in one of these headers:

* `Authorization: Bearer <token>`, as in the OpenAI format
* `x-api-key: <token>`, as in the Anthropic format
* `x-goog-api-key: <token>`, as in the Gemini format

#### Endpoints

| Format    | Endpoint                                                                             |
| --------- | ------------------------------------------------------------------------------------ |
| OpenAI    | `POST /chat/completions`, `POST /completions`, `POST /responses`, `POST /embeddings` |
| Anthropic | `POST /messages`, `POST /messages/count_tokens`                                      |
| Gemini    | `POST /v1beta/models/{model}:generateContent` and `:streamGenerateContent`           |
| All       | `GET /models` lists the models your token can call                                   |

For the Gemini endpoints, use `https://api.theblockbrain.ai/genai` as the base and add the path above.

#### Which models you can call

You can call the models that are switched on for your organization in [AI Models](https://docs.blockbrain.ai/for-admins/ai-models.md), and your organization's auto routers. `GET /models` returns the exact list for your token. A model that is not on the list answers `403`.

#### Example

```bash
curl https://api.theblockbrain.ai/genai/v1/chat/completions \
  -H "Authorization: Bearer $BLOCKBRAIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google-gemini-3.8-flash",
    "messages": [{ "role": "user", "content": "Hello" }]
  }'
```

#### Costs and limits

Every call consumes Compute Blocks, priced by the model that answered it. Usage counts against your own limit and, if one is set, the limit of the token. When a limit is reached, requests answer `429`. See [Setting Limit](https://docs.blockbrain.ai/for-admins/cost-control/setting-limit.md).

#### Errors

| Status | Meaning                                                                                       |
| ------ | --------------------------------------------------------------------------------------------- |
| `401`  | The token is missing, invalid or expired                                                      |
| `403`  | The LLM API is not enabled for your organization, or the model is not available to your token |
| `429`  | A Compute Block limit is reached                                                              |
| `503`  | The LLM API is temporarily unavailable, try again shortly                                     |

{% hint style="info" %}
To work with knowledge bots, knowledge bases and workflows through an API, see the [Knowledge Bots API](https://api.docs.blockbrain.ai).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.blockbrain.ai/for-admins/llm-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
