---
name: monk
description: Monk AI API — OpenAI-compatible (and Anthropic-compatible) chat endpoint at https://monk.party with four auto-fallback model groups (monk, monk-fast, monk-coding, monk-free) plus pay-as-you-go monk-opus (Claude Opus 5.5). Use when the user mentions Monk, MONK_URL / MONK_KEY, or wants to run chat, code generation, or agent/tool workloads through their Monk API key.
---

# Monk

Monk is a hosted AI API at `https://monk.party`. One API key, four ready-made model groups, automatic fallback. It speaks the OpenAI Chat Completions format, the OpenAI Responses format, and the Anthropic Messages format, so most SDKs and coding agents work by only changing the base URL and key.

## Setup

```bash
export MONK_URL="https://monk.party"
export MONK_KEY="<your Monk API key>"   # starts with sk-monk-
```

Every request goes to `${MONK_URL}/v1/...` with the header:

```
Authorization: Bearer ${MONK_KEY}
```

OpenAI-style SDKs: set `baseURL` / `base_url` to `${MONK_URL}/v1` and `apiKey` to `${MONK_KEY}`.

## Models

```bash
curl -s "$MONK_URL/v1/models" -H "Authorization: Bearer $MONK_KEY"
```

Response:

```json
{ "object": "list", "data": [
  { "id": "monk",        "object": "model", "created": 0, "owned_by": "monk" },
  { "id": "monk-fast",   "object": "model", "created": 0, "owned_by": "monk" },
  { "id": "monk-coding", "object": "model", "created": 0, "owned_by": "monk" },
  { "id": "monk-free",   "object": "model", "created": 0, "owned_by": "monk" },
  { "id": "monk-opus",   "object": "model", "created": 0, "owned_by": "monk" }
]}
```

| Model id | Best for |
|---|---|
| `monk` | General-purpose, balanced quality. Default choice. |
| `monk-fast` | Lowest latency: short chat, translation, simple Q&A. |
| `monk-coding` | Code generation, debugging, refactors, agents and tool use, long technical work. |
| `monk-free` | Free-tier models only; good for light or non-critical tasks. |
| `monk-opus` | Claude Opus 5.5 for planning, architecture and hard reasoning. Pay as you go from the user's prepaid Opus wallet (https://monk.party/me/#opus); returns 402 `insufficient_balance` when empty. Good pattern: `monk-opus` as the lead agent, `monk` for sub-agents. |

Each id is a **fallback group**: Monk tries the group's models in a fixed order and, if one fails or is busy, automatically moves on to the next. You do not need to implement retries across providers yourself.

Rules:
- Always use an `id` returned by `/v1/models` as the `model` field. Monk uses exactly the group you ask for and never switches you to a different group.
- Any other model name is rejected (see Errors).
- If `model` is omitted on a chat request, `monk` is used.
- The `model` field in a response may name the specific model inside the group that answered.

## Chat — OpenAI format

`POST $MONK_URL/v1/chat/completions`

Non-streaming:

```bash
curl -s -X POST "$MONK_URL/v1/chat/completions" \
  -H "Authorization: Bearer $MONK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "monk",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": false
  }'
```

```json
{ "id": "...", "object": "chat.completion", "model": "...",
  "choices": [{ "index": 0, "message": { "role": "assistant", "content": "Hello! How can I help?" }, "finish_reason": "stop" }],
  "usage": { "prompt_tokens": 9, "completion_tokens": 7, "total_tokens": 16 } }
```

Streaming (Server-Sent Events):

```bash
curl -N -X POST "$MONK_URL/v1/chat/completions" \
  -H "Authorization: Bearer $MONK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "monk",
    "messages": [{"role": "user", "content": "Write a haiku about the sea."}],
    "stream": true
  }'
```

The stream emits `data: {"choices":[{"delta":{"content":"..."}}]}` lines and ends with `data: [DONE]`. Lines starting with `:` are keep-alive comments; ignore them.

JavaScript (OpenAI SDK):

```js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: `${process.env.MONK_URL}/v1`, apiKey: process.env.MONK_KEY });
const stream = await client.chat.completions.create({
  model: "monk-coding",
  messages: [{ role: "user", content: "Write a Python function that reverses a string." }],
  stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content || "");
```

Python (OpenAI SDK):

```python
import os
from openai import OpenAI
client = OpenAI(base_url=f"{os.environ['MONK_URL']}/v1", api_key=os.environ["MONK_KEY"])
r = client.chat.completions.create(model="monk", messages=[{"role": "user", "content": "Hi"}])
print(r.choices[0].message.content)
```

### Web search augmentation (chat only)

On `/v1/chat/completions`, Monk may automatically run a web search for questions that look time-sensitive (news, prices, "today", "latest", explicit "search the web") and append the top results to your last user message as context. `monk-coding` only does this when you explicitly ask for a search.

Control it per request:
- Turn off: header `X-Monk-Web-Search: off`, or body field `"web_search": false`
- Force on: header `X-Monk-Web-Search: on`, or body field `"web_search": true`

Agents that need the exact prompt delivered unchanged should send `X-Monk-Web-Search: off`.

## Chat — Anthropic Messages format

`POST $MONK_URL/v1/messages` (for Anthropic SDKs and Claude-style agents):

```bash
curl -s -X POST "$MONK_URL/v1/messages" \
  -H "Authorization: Bearer $MONK_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "monk-coding",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
```

```json
{ "id": "...", "type": "message", "role": "assistant", "model": "...",
  "content": [{ "type": "text", "text": "Hello!" }],
  "stop_reason": "end_turn", "usage": { "input_tokens": 9, "output_tokens": 3 } }
```

Add `"stream": true` for Anthropic-style SSE events.

## Chat — OpenAI Responses format

`POST $MONK_URL/v1/responses`:

```bash
curl -s -X POST "$MONK_URL/v1/responses" \
  -H "Authorization: Bearer $MONK_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "monk", "input": "Hello!" }'
```

## Errors

| Status | `error.code` | Meaning / what to do |
|---|---|---|
| 401 | `invalid_api_key` | Key missing, malformed (must start with `sk-monk-`), or inactive. Check `MONK_KEY`. |
| 401 | `key_expired` | Subscription has expired. Renew, then retry. |
| 404 | `model_not_found` | `model` is not one of the ids from `/v1/models`. Use `monk`, `monk-fast`, `monk-coding`, `monk-free` or `monk-opus`. |
| 429 | `daily_quota_exceeded` | Daily usage limit for this key reached. Resets at 00:00 UTC. |
| 429 | `burst_limit` / `concurrency_limit` | Too many requests at once. Wait for the `Retry-After` header (seconds), then retry. |
| 503 | — | All models in the group are busy right now. Wait for `Retry-After` if present (otherwise a few seconds) and retry, or try another group. |

Retry guidance: honor `Retry-After`, use exponential backoff, and avoid tight retry loops — repeated rapid retries trigger `burst_limit`.

## Use this skill

Paste this to your AI:

```
Read this skill and use it: https://monk.party/skills/monk/SKILL.md
```
