# legit2compute / legit2cloud: quickstart for AI agents

You are setting up a project to use legit2compute (also sold as legit2cloud). One API key covers:
- **Chat and vision models** through an OpenAI-compatible API.
- **Media jobs**: images, image edits, video, music, voiceovers and sound effects (submit, poll, download).

Billing is prepaid credit (1 credit = 1 US cent). There is no subscription.

## 1. Get the key from your human

You cannot sign up for them. Ask the user for their API key and tell them where to get it:
https://www.legit2compute.com/developers/signup

Signing up with Google, Discord, GitHub or Twitch includes a small free trial balance.

Keys start with `l2ck_` or `l2cloud_`. Store the key as an environment variable named `L2C_API_KEY`:
- Put it in the project's `.env` and make sure `.env` is in `.gitignore`.
- Never write the key into source code, a commit, a log or your reply.

## 2. Chat and vision models (OpenAI-compatible)

- Base URL: `https://api.legit2compute.com/nodes/llm/v1`
- Auth: `Authorization: Bearer $L2C_API_KEY` (the OpenAI SDKs do this for you).
- Model: `l2c/auto` picks the cheapest loaded model that fits each request. Any ID from `GET https://api.legit2compute.com/nodes/llm/v1/models` also works.

Python:

```python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.legit2compute.com/nodes/llm/v1", api_key=os.environ["L2C_API_KEY"])
r = client.chat.completions.create(model="l2c/auto", messages=[{"role": "user", "content": "Say hello in five words."}])
print(r.choices[0].message.content)
```

JavaScript:

```js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.legit2compute.com/nodes/llm/v1", apiKey: process.env.L2C_API_KEY });
const r = await client.chat.completions.create({ model: "l2c/auto", messages: [{ role: "user", content: "Say hello in five words." }] });
console.log(r.choices[0].message.content);
```

Streaming, tool calling and image inputs (an `image_url` content part with a base64 data URL) work the OpenAI way.

## 3. Media jobs (images, video, music, voice, sound effects)

The easiest way is the agent skill. It is a folder with instructions and a dependency-free Python CLI:
https://www.legit2compute.com/developers/skill.zip

Unzip it into `.claude/skills/` (Claude Code), `~/.hermes/skills/` (Hermes Agent) or `~/.openclaw/skills/` (OpenClaw), then follow its SKILL.md. Start with its `me` command to see which pipelines the key can run and the credit left.

Raw HTTP, header `x-api-key: $L2C_API_KEY`, base `https://api.legit2compute.com`:

```bash
# what this key can run, and the balance
curl https://api.legit2compute.com/me -H "x-api-key: $L2C_API_KEY"
# 1. submit
curl https://api.legit2compute.com/jobs -H "x-api-key: $L2C_API_KEY" -H "content-type: application/json" \
  -d '{"pipeline": "image_generate", "inputData": {"prompt": "a red fox sitting in fresh snow at sunrise, photo"}}'
# 2. poll until "status" is "completed" (every 5-10 s; video takes minutes)
curl https://api.legit2compute.com/jobs/<job_id> -H "x-api-key: $L2C_API_KEY"
# 3. download (redirects to the file, so use -L)
curl -L -o fox.png https://api.legit2compute.com/jobs/<job_id>/download -H "x-api-key: $L2C_API_KEY"
```

Pipelines on a new key: `image_generate`, `image_edit`, `video_t2v`, `video_i2v`, `video_lipsync`, `video_motion`, `voice_generate`, `music_generate`, `sound_effects`. Trust what `/me` returns over this list.

## 4. Errors you will meet

- **401**: the key is missing or wrong. Ask the user to check it.
- **402**: out of credit. The user tops up at https://www.legit2compute.com/developers.
- **503 with `"warming": true`**: that model is loading. Retry in a minute or two, or use `l2c/auto`.
- **404 "unknown pipeline"**: the key cannot run that pipeline. Check `/me`.

## 5. Finish

Make one small test call (a chat reply, or one image) and show the user the result. Tell them what it cost: the activity page is https://www.legit2compute.com/developers/activity.

More: API docs https://www.legit2compute.com/docs · models and prices https://www.legit2compute.com/models · media prices https://www.legit2compute.com/media
