# kosa8 AI

7 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## Ask kosa8: answers from the docs and your live status, with links and proposed actions[#]

POST`/v1/ask`scope sandboxes:read

kosa8 AI runs on Cloudflare Workers AI through kosa8's AI gateway: no model key, and the text stays within Cloudflare. Its output is data: it never approves, merges, deletes or widens access, and proposed actions are buttons that run the normal flows. Each model call is metered like other gateway use, capped per hour, and identical inputs are answered from a cache. Send Accept: text/event-stream (or stream: true) for server-sent events: meta, delta {text}, then done (the JSON below) or error. Capped per member per hour (429 ask_rate_limit with retry_after_s); 503 ai_off when switched off.

JSON body

`question`requiredstring

1-2000 characters

`page`string | null

The app page asked from, e.g. billing

`repo`string | null

owner/name, for a Do it for me task

`history`array of object

Up to 4 earlier turns

`stream`boolean

—

Responses

200400401403429503

```
curl -s -X POST https://api.kosa8.com/v1/ask \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Why it failed: one line on why, one suggested fix, and the failure class[#]

POST`/v1/ai/explain`scope sandboxes:read

kosa8 AI runs on Cloudflare Workers AI through kosa8's AI gateway: no model key, and the text stays within Cloudflare. Its output is data: it never approves, merges, deletes or widens access, and proposed actions are buttons that run the normal flows. Each model call is metered like other gateway use, capped per hour, and identical inputs are answered from a cache. When the model is capped or off, kosa8's rules answer (source: rules).

JSON body

`kind`required"bot_run" | "pipeline_run" | "agent_task" | "gh_trigger"

—

`id`requiredstring

The run's, task's or request's id

Responses

200400401403404

```
curl -s -X POST https://api.kosa8.com/v1/ai/explain \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## One-click agent tasks: Fix a failing test, Explain this error, Summarize this repo, Write a README[#]

GET`/v1/agent/templates`scope sandboxes:read

kosa8 AI runs on Cloudflare Workers AI through kosa8's AI gateway: no model key, and the text stays within Cloudflare. Its output is data: it never approves, merges, deletes or widens access, and proposed actions are buttons that run the normal flows. Each model call is metered like other gateway use, capped per hour, and identical inputs are answered from a cache.

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/agent/templates \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Recent kosa8 AI agent tasks[#]

GET`/v1/agent/tasks`scope sandboxes:read

kosa8 AI runs on Cloudflare Workers AI through kosa8's AI gateway: no model key, and the text stays within Cloudflare. Its output is data: it never approves, merges, deletes or widens access, and proposed actions are buttons that run the normal flows. Each model call is metered like other gateway use, capped per hour, and identical inputs are answered from a cache.

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/agent/tasks \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Start a kosa8 AI agent task on a repo or a sandbox; changes come back as a draft pull request[#]

POST`/v1/agent/tasks`scope sandboxes:write

kosa8 AI runs on Cloudflare Workers AI through kosa8's AI gateway: no model key, and the text stays within Cloudflare. Its output is data: it never approves, merges, deletes or widens access, and proposed actions are buttons that run the normal flows. Each model call is metered like other gateway use, capped per hour, and identical inputs are answered from a cache. Send repo (owner/name through your GitHub connection) or sandbox_id. The agent runs in a sandbox; its short-lived kosa8 AI token is held by the egress broker, never in the sandbox. Draft pull requests only. 10 tasks an hour and 3 at once per organization (429 agent_rate_limit). Poll GET /v1/agent/tasks/{id}.

JSON body

`task`string

What to do, in one sentence

`template`string | null

A template id instead of, or with, task

`repo`string | null

owner/name

`ref`string | null

Branch, tag or commit

`sandbox_id`string | null

sbx_…

`draft_pr`boolean

Default true; false keeps the changes in the sandbox

Responses

202400401402403404429503

```
curl -s -X POST https://api.kosa8.com/v1/agent/tasks \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## One agent task, with its steps rail, result and cost[#]

GET`/v1/agent/tasks/{id}`scope sandboxes:read

kosa8 AI runs on Cloudflare Workers AI through kosa8's AI gateway: no model key, and the text stays within Cloudflare. Its output is data: it never approves, merges, deletes or widens access, and proposed actions are buttons that run the normal flows. Each model call is metered like other gateway use, capped per hour, and identical inputs are answered from a cache.

Parameters

`id`requiredpath · string

Task id (agt_…)

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/agent/tasks/$SBX \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Stop an agent task; its own sandbox is deleted[#]

POST`/v1/agent/tasks/{id}/cancel`scope sandboxes:write

kosa8 AI runs on Cloudflare Workers AI through kosa8's AI gateway: no model key, and the text stays within Cloudflare. Its output is data: it never approves, merges, deletes or widens access, and proposed actions are buttons that run the normal flows. Each model call is metered like other gateway use, capped per hour, and identical inputs are answered from a cache.

Parameters

`id`requiredpath · string

Task id (agt_…)

Responses

200401403404409

```
curl -s -X POST https://api.kosa8.com/v1/agent/tasks/$SBX/cancel \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

---
Source: https://docs.kosa8.com/api/kosa8-ai/
