> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infinitecompute.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# API overview

> Manage GPU servers, volumes and usage from code: addresses, authentication, errors, retries and limits.

The Infinite Compute API does what the console does, from your own scripts, CI pipelines and tools: launch, stop, park and delete GPU servers, manage volumes and SSH access, and read usage. The same rules apply as in the console, so a request the console would refuse is refused here too.

There are three ways to use it:

* **The API itself:** plain HTTPS and JSON. The [API reference](https://docs.infinitecompute.ai/api-reference/keys/me.md) lists every endpoint.
* **The [`ic` command line](https://docs.infinitecompute.ai/api/cli)**, for your terminal and shell scripts.
* **The [Terraform provider](https://docs.infinitecompute.ai/api/terraform.md)**, to describe servers and volumes as code.

> [!NOTE]
>
> The API, the command line and the Terraform provider are in beta, and the API is turned on per project. If you can't use it in your project, [contact support](https://docs.infinitecompute.ai/guides/getting-help.md).

## Address

All requests go to your console address followed by `/api/public/v1`:

```text theme={null}
https://<your-console-address>/api/public/v1
```

Your console address is in your welcome email.

## Authentication

Every request carries an API key in the `Authorization` header:

```bash theme={null}
curl -H "Authorization: Bearer $INFINITECOMPUTE_API_KEY" \
  https://<your-console-address>/api/public/v1/me
```

Create keys in the console: open the menu at the bottom of the sidebar and choose **API keys**. A key acts for the person who created it, in one project. See [API keys](https://docs.infinitecompute.ai/api/keys.md).

`GET /me` tells you which project, person and key a key belongs to. It's the quickest way to check a key works.

## Requests and responses

* JSON in and out, field names in `snake_case`, times in RFC 3339 (UTC).
* Unknown fields in a request body are refused, so a typo can't be silently ignored.
* Every response carries an `X-Request-Id` header. Quote it when you contact support. You can send your own `X-Request-Id` (8 to 128 letters, digits, `.`, `_`, `:` or `-`) to match our logs to yours.

## Errors

Every error has the same shape:

```json theme={null}
{
  "error": {
    "code": "invalid_argument",
    "message": "image: not built for this GPU; pick an image whose gpu_models include it",
    "request_id": "req-3f1c..."
  }
}
```

Branch on `code`; `message` is for people and may change.

| HTTP | `code` | Meaning |
| - | - | - |
| 400 | `invalid_argument` | Something in the request is wrong. The message says what. |
| 401 | `unauthenticated` | Missing, invalid, expired or revoked API key. |
| 402 | `insufficient_credit` | The account is out of credit: top up before launching or resuming GPU servers. |
| 403 | `permission_denied` | The key may not do this, for example a read-only key on a write. |
| 404 | `not_found` | It doesn't exist, or it isn't in your project. |
| 409 | `conflict` | The resource is busy or in the wrong state, for example parking a server that is already parked. |
| 422 | `quota_exceeded` | It would go over your project's quota. |
| 429 | `rate_limited` | Too many requests. Wait for the number of seconds in `Retry-After`. |
| 500 | `internal` | Something went wrong on our side. Retry later; contact support if it persists. |
| 503 | `capacity_unavailable` | No capacity for this right now, or the feature isn't available to your project. |

## Long-running work

Creating, deleting and acting on a server (start, stop, reboot, park, resume) answer at once with `202 Accepted` and the resource in its current state. Poll `GET /servers/{id}` until it reaches the state you want.

A server's `status` is one of:

| Status | Meaning |
| - | - |
| `building` | Being created. |
| `active` | Running. |
| `busy` | An action is in progress, such as a reboot, park or resume. |
| `stopped` | Stopped. It keeps its GPU and its disk. |
| `parked` | Parked: the GPU is released and GPU billing stops; the disk is kept. Resume to run it again. |
| `deleting` | Being deleted. |
| `error` | Failed. `error_reason` says why. |

Volumes use `creating`, `available`, `in_use`, `busy`, `deleting` and `error`; backups use `creating`, `available`, `restoring`, `busy`, `deleting` and `error`. Treat any value you don't recognise as "something else", since new values may be added.

## Safe retries

`POST` requests that create something (servers, volumes, backup restores) accept an `Idempotency-Key` header. Send a unique value, such as a UUID, with each new request, and the same value when you retry it:

```bash theme={null}
curl -X POST https://<your-console-address>/api/public/v1/servers \
  -H "Authorization: Bearer $INFINITECOMPUTE_API_KEY" \
  -H "Idempotency-Key: 7d0e5c1a-9b2f-4c55-8f0e-2a1b3c4d5e6f" \
  -H "Content-Type: application/json" \
  -d '{"name": "llm-finetune-01", "server_type": "<server type>", "image": "<image>", "ssh_key": "laptop"}'
```

* A retry with the same key and the same request gets the first response back, with the header `Idempotent-Replayed: true`. Nothing is created twice.
* The same key with a different request is refused with `invalid_argument`.
* A retry while the first request is still running gets `conflict`; wait and retry.
* Keys are kept for 24 hours.

The command line and the Terraform provider send one for you.

## Pages of results

Lists answer `{"data": [...], "next_cursor": "..."}`. Ask for up to 200 items with `?limit=` (default 50). When `next_cursor` isn't `null`, pass it as `?cursor=` to get the next page.

## Limits

* **10 requests a second** per API key, with bursts of up to 30.
* **5 server launches a minute** per project.

Over a limit you get `429 rate_limited` and a `Retry-After` header.

## Sites

Each server type runs at one site, shown as `site` on the type. Volumes are created at a site and attach only to servers at the same site; a backup restores at its own site. `GET /server-types` lists the types, and so the sites, your project can use. The server types available to you depend on your agreement.

## Related

> [card] [API keys](https://docs.infinitecompute.ai/api/keys.md)
>
> Create, scope and revoke keys.

> [card] [Command line](https://docs.infinitecompute.ai/api/cli.md)
>
> The `ic` command for your terminal.

> [card] [Terraform](https://docs.infinitecompute.ai/api/terraform.md)
>
> Servers and volumes as code.

> [card] [API reference](https://docs.infinitecompute.ai/api-reference/keys/me.md)
>
> Every endpoint, request and response.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.