# Call Athena from your own apps

**Athena** is a model in the aixplain Marketplace, so you can call it from anywhere with an aixplain API key: your own app, a script, another AI framework or an MCP client. This article explains how to get a key and call Athena through the OpenAI-compatible API and through MCP.

> Athena is available to every aixplain workspace on cloud. You pay for the models that answer, from the credits of the workspace your API key belongs to.

## What you need

- **An aixplain API key:** create one in the aixplain app under **[Settings → API keys](https://app.aixplain.com/team/settings?tab=api-keys)**. The full key is shown only once, so copy it then.
- **Athena's model name:** `aixplain/llm-router/aixplain`. Its Marketplace ID, `6ab559cabbbd3609ac7e86cf`, works too.

> **Important:** Treat the API key like a password. Keep it in an environment variable or a secret store, never in code you share.

## Call Athena through the OpenAI-compatible API

Athena answers the OpenAI chat completions format at `https://models.aixplain.com/api/v1`. Any client, framework or tool that lets you set an OpenAI base URL can use it.

From a terminal:

```bash
curl https://models.aixplain.com/api/v1/chat/completions \
  -H "Authorization: Bearer $AIXPLAIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "aixplain/llm-router/aixplain",
    "messages": [{"role": "user", "content": "Why is my checkout test flaky?"}]
  }'
```

In Python, with the OpenAI client:

```python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["AIXPLAIN_API_KEY"], base_url="https://models.aixplain.com/api/v1")

completion = client.chat.completions.create(
    model="aixplain/llm-router/aixplain",
    messages=[{"role": "user", "content": "Why is my checkout test flaky?"}],
)
print(completion.choices[0].message.content)
```

Athena supports streaming, tools, `max_tokens`, `temperature`, `reasoning_effort` and `response_format`, like other chat models.

### See which model answered

Every response carries a `router` field with the tier Athena chose and the model that served the request. You're billed at that model's price.

```python
router = completion.model_extra["router"]
print(router["servedTier"], router["model"]["name"])
```

`servedTier` is `fat` (Deep), `slim` (Standard) or `fast` (Quick).

### Choose the tier yourself

To skip the classifier for a request, set `router_tier` to `fat`, `slim` or `fast`. With the OpenAI client, pass it as `extra_body={"router_tier": "fast"}`. Athena may still serve the request on a stronger tier, and `router` shows which one did.

### Use Athena in other AI projects

Coding agents, chat apps and AI frameworks that accept a custom OpenAI-compatible provider can run on Athena. In the tool's settings:

1. Add a custom provider with the base URL `https://models.aixplain.com/api/v1`.
2. Enter your aixplain API key.
3. Set the model to `aixplain/llm-router/aixplain`.

## Call Athena through MCP

Every model in the Marketplace is also a hosted MCP server, Athena included. Add it to any MCP client that connects to a URL, with your API key:

```json
{
  "mcpServers": {
    "athena": {
      "url": "https://models-mcp.aixplain.com/mcp/aixplain%2Fllm-router%2Faixplain",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY",
        "Accept": "application/json, text/event-stream"
      }
    }
  }
}
```

Clients that only run local commands can reach the same URL through the `mcp-remote` bridge. For both setups and a connection test, see **[MCP servers](https://docs.aixplain.com/api-reference/marketplace)** in the Agents SDK docs.

> **Note:** You can also run Athena from the aixplain Marketplace Search MCP server, which can run any Marketplace model. Pass your request as the `data` input.

## Pricing and usage

Each request costs what the model that answered it costs, from your workspace's credits. Your workspace's usage page breaks usage down by API key, and you can cap a key's spending. See **[Your account, plans and billing](https://www.aixplain.com/support/articles/account-plans-and-billing)**.

## Limitations

- To choose the models behind each tier, create your own router with **[Automode](https://www.aixplain.com/support/articles/set-up-automode-with-your-own-models#create-your-own-router-in-the-aixplain-os)**, then call it by its ID like any other model.
- Athena runs on aixplain on cloud. For routing on your own servers, ask us at **care@aixplain.com**.

## Troubleshooting

### I get "err.not_enough_balance"

The workspace your key belongs to is out of credits. Top it up, then try again.

### I get "Forbidden" or 401

The key is wrong, deleted or expired. Create a new key and try again.

## Get help

- **Build an agent on Athena:** see **[Run your agents on Athena](https://www.aixplain.com/support/articles/run-your-agents-on-athena)**.
- **API reference:** see the **[Agents SDK docs](https://docs.aixplain.com)**.
- **Report a problem:** email **care@aixplain.com** with the request, the time and the error you got.
