# Cap Infra

Cheap, fast & reliable video infrastructure. Upload a video and get back adaptive HLS up to 4K, an MP4, a poster and a hosted player. Uploading and encoding are free, storage is from $0.85 per 1,000 minutes a month, delivery is billed per delivered minute and speech to text is $0.10 per audio hour.

## Set it up with an agent

Give this prompt to your coding agent. It is the same prompt the Copy prompt button on this page copies.

```text
Set up Cap Infra in this project so it can upload and play video.

Cap Infra is Cap's video and speech API. All you need is the app's secret key and the REST API. Read https://cap.so/openapi.json and https://cap.so/docs/api/rest-api first. Use only the methods and paths documented there, and take every field name from the OpenAPI document.

1. Find the secret key. I created the app in the Cap Infra console and put its secret key (csk_) in this project's local environment file as CAP_SECRET_KEY. Check that the variable is set without printing its value, and that the file is ignored by git. If it is missing, stop and ask me to add it to the file. Never ask me to paste the key into the chat, and never print, log or commit it.
2. Keep the key on the server. Send it only from server code, as Authorization: Bearer followed by the key. It never goes into browser code, a client bundle or a public environment variable.
3. Create uploads on the server. For a signed-in user, call POST /api/developer/v1/uploads and give the browser only what it returns for that one video: the upload token (cut_), the video id and the embed URL. In production, set corsOrigin to the site's origin.
4. Upload from the browser. With the upload token as the Bearer credential, call POST /api/developer/sdk/v1/upload/multipart/initiate, then POST /api/developer/sdk/v1/upload/multipart/presign-part with up to 50 part numbers in one request. PUT each part to its signed URL and keep the ETag it answers with, then call POST /api/developer/sdk/v1/upload/multipart/complete. If a call answers 401 with the code upload_token_expired, get a new token from the server with POST /api/developer/v1/uploads/{id}/token and continue with the same uploadId and ETags.
5. Wait until it plays. From the server, poll GET /api/developer/v1/videos/{id}/status every 3 seconds. Stop when status is ready or errored, and show errorReason if it failed.
6. Play it. Show the video with its embedUrl, or build a player from hlsUrl and mp4Url in GET /api/developer/v1/videos/{id}. Use hlsUrl when it is present and mp4Url otherwise. shareUrl is the link to send to someone. Video that viewers stream is billed per delivered minute.
7. Transcribe when I ask. Transcripts are billed per audio hour, so confirm with me first. For a public URL call POST /api/developer/v1/transcripts. For a file call POST /api/developer/v1/transcripts/uploads, PUT the file to the signed URL it returns, then call POST /api/developer/v1/transcripts/{id}/start. Poll GET /api/developer/v1/transcripts/{id} every 5 seconds until status is complete or error.
8. Stay inside the limit. A secret key allows 300 requests a minute across every endpoint. After a 429, wait for the number of seconds in the Retry-After header before you send the request again.
9. Watch the credits. GET /api/developer/v1/usage shows the balance and whether uploads are allowed. A 402 means the app needs credit, so tell me and I will add it in the console.
10. Use the MCP server if you want tools. Cap Infra has a hosted MCP server at https://cap.so/api/developer/mcp that takes the same secret key as Authorization: Bearer. Its requests count toward the same limit.

Finish by uploading one short test video through the code you wrote. Ask me first, because stored video is billed one month when it becomes ready, then daily. Then tell me what you changed and give me the video's shareUrl, and ask what I want to build next.
```

## Links

- Get started, from a new app to a playing video: https://cap.so/docs/api/get-started
- REST reference: https://cap.so/docs/api/rest-api
- OpenAPI 3.1 description: https://cap.so/openapi.json
- Webhooks: https://cap.so/docs/api/webhooks
- Billing: https://cap.so/docs/api/billing
- Hosted MCP server: https://cap.so/api/developer/mcp, with the secret key as Authorization: Bearer. Setup: https://cap.so/docs/api/get-started#10-use-with-agents-mcp
- MCP server card: https://cap.so/.well-known/mcp/infra/server-card.json
- Local MCP server, which uploads a file from disk in one call: npx -y @cap.so/infra-mcp with the key in CAP_SECRET_KEY. Setup: https://www.npmjs.com/package/@cap.so/infra-mcp
- Console, where an app and its keys are created: https://cap.so/dashboard/infra
- Every Cap Infra doc in one Markdown file: https://cap.so/infra/llms-full.txt
- Everything about Cap for agents: https://cap.so/llms.txt

Every page under /docs is also available as Markdown: add .md to its URL or send Accept: text/markdown.
