# Use your own OpenAI key

Swarm agents run on OpenAI models. Add your OpenAI API key and new swarms send their model calls to OpenAI with it, so OpenAI bills you directly.
Page: https://acyclic.dev/guides/openai-key

## 1. Create an OpenAI key

Create a project key at [platform.openai.com/api-keys](https://platform.openai.com/api-keys). The project needs access to `gpt-5.6-sol` and `gpt-5.6-luna`.

## 2. Add it to Acyclic

From the CLI (0.0.9 or later), pipe the key in. Or, on [Credentials](/dashboard/settings/credentials), under Add a key, choose Model provider, then OpenAI, paste the key and click Add key. Either way we check the key with OpenAI before saving it.

```sh
pbpaste | acyclic swarm keys add --label prod
```

## 3. Start a swarm as usual

There's nothing to change. Swarms from the CLI, the dashboard and MCP all use the key.

```sh
acyclic swarm run --watch --task "<your task>"
```

## 4. Check it is in use

`acyclic swarm keys ls` lists your keys. On Credentials, each key shows when it was last used, and Usage log lists every call by swarm. Revoke one with `acyclic swarm keys rm <id>`.

```sh
acyclic swarm keys ls
```

## Cost

OpenAI bills your key for model calls. Your Acyclic credit pays only for sandbox time. A swarm still stops once its model calls and sandbox time, at list prices, reach your remaining Acyclic credit, so keep some credit even though you aren't charged for the models.

## How it works

- When a swarm starts, Acyclic gives it a short-lived token tied to your key and to that one swarm.
- Agents send model calls to acyclic.dev, which adds your key and forwards them to OpenAI. Your key never enters an agent's box.
- Cancelling the swarm, or revoking the key, stops its model calls at once.

## Notes

- New swarms use your newest active OpenAI key. A swarm keeps the key it started with.
- If a key is revoked or expires, swarms still using it fail their next model call. New swarms go back to Acyclic's keys.
- Prompts pass through acyclic.dev on their way to OpenAI, just as they do without your key.
- Codex swarms (`--harness codex`) and swarms that choose a model (`--model`, see [models](/guides/models)) still use Acyclic's keys.
- Only OpenAI keys are used for now. You can store Anthropic and OpenRouter keys, but swarms don't use them yet.
