> ## Documentation index
> Fetch the complete index at: https://maritime.sh/llms.txt
> Setup procedure for AI agents (install, sign in, deploy, verify): https://maritime.sh/agents.md
> This page as HTML: https://maritime.sh/docs/llm

# Maritime LLM

Run agents

Maritime LLM is an OpenAI-compatible model endpoint for your agents. Each call uses a per-agent token
and draws down your prepaid [AI credits](https://maritime.sh/docs/billing#ai-credits). You do not need
an OpenAI account.

## Endpoint and token

| Variable | Value |
| --- | --- |
| `OPENAI_BASE_URL` | `https://api.maritime.sh/api/llm/v1` |
| `OPENAI_API_KEY` | A per-agent token that starts with `mllm_` |

Maritime writes both variables to the agent's environment. There is no account-wide key, and the
endpoint accepts OpenAI API paths with `GET` and `POST`. It speaks the OpenAI format only, so Anthropic
clients need your own `ANTHROPIC_API_KEY`.

## Get the credentials

Templates and known harnesses, such as OpenClaw, Hermes, ZeroClaw, CrewAI, and LangGraph, get both
variables when you create the agent.

An agent with framework `custom`, `docker`, or `auto` starts with neither variable, because Maritime
does not know how your application reads them. To add them, use one of these options:

- At create, send `"useMaritimeLlm": true` in `POST /api/agents`.
- On an existing agent, press **Use Maritime LLM** on the Env tab, then restart the agent.
- From the API, call `POST /api/agents/{id}/reset-llm`, then restart the agent. The API key needs the `secrets` scope.

The last two options replace an `OPENAI_API_KEY` that the agent already has.

## Call a model

Any client that reads the two variables works without other configuration. This example runs inside
the agent:

```python
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
	model="gpt-5.4",
	messages=[{"role": "user", "content": "Say hello."}],
)
print(response.choices[0].message.content)
```

The same call with curl:

```bash
curl "$OPENAI_BASE_URL/chat/completions" \
	-H "Authorization: Bearer $OPENAI_API_KEY" \
	-H "Content-Type: application/json" \
	-d '{"model": "gpt-5.4", "messages": [{"role": "user", "content": "Say hello."}]}'
```

## EU routing

EU routing is set per account and is available on request. There is no separate EU URL. You keep the
same base URL and token, and Maritime sends calls that use an `mllm_` token to `eu.api.openai.com`.

- OpenAI processes these calls in the EU. Maritime has confirmed `gpt-5.4`, `gpt-5-mini`, `gpt-5.5`, and `gpt-6-luna` on this route.
- A routed call never falls back to the US. If Maritime cannot select the EU route, the call returns `503`.
- Maritime does not store the content of routed calls.
- Requests pass through Maritime's US-hosted endpoint in memory. Usage metadata (model, token counts, cost, and request ID) is stored in the US.
- Calls with your own OpenAI key are not routed. See the next section.

## Use your own key

To pay OpenAI directly, set `OPENAI_API_KEY` to your own key as a secret env var. Calls with your own
key do not use AI credits and have no Maritime spend limit.

If the agent keeps the Maritime base URL, the endpoint forwards your key to `api.openai.com`. This also
applies to an account that has EU routing.

## Errors

The endpoint returns OpenAI's own response and status code for a call that reaches OpenAI. Maritime
adds these errors:

| Status | Meaning |
| --- | --- |
| `401` | The request has no `Authorization` bearer token |
| `402` | The account has no AI credits left. The error code is `budget_exhausted`. Do not retry until you add credits |
| `404` | The token belongs to an agent that no longer exists |
| `429` | The agent reached its monthly spend limit. Retry after the `Retry-After` value, or raise the limit (see [spend limits](https://maritime.sh/docs/add-ons#models)) |
| `503` | Maritime could not select a route for the call. Retry later |

## Related pages

- [AI credits](https://maritime.sh/docs/billing#ai-credits)
- [Deploy any container](https://maritime.sh/docs/frameworks/custom)
- [How agents reach a model](https://maritime.sh/docs/how-it-works#how-agents-reach-a-model)
