Skip to content

Commit af4de25

Browse files
committed
api: multimodal content, real usage stats, conv file for multi-turn, append-system-prompt header
1 parent 61d1bfb commit af4de25

2 files changed

Lines changed: 229 additions & 86 deletions

File tree

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# 🧠 docker-claude-code
22

3-
[Claude Code](https://claude.com/product/claude-code) in a Docker container. No host installs. No permission nightmares. Just vibes and `--dangerously-skip-permissions`.
3+
[Claude Code](https://claude.com/product/claude-code) in a Docker container. No host installs. No permission nightmares. Just vibes and `--dangerously-skip-permissions`. Use it as a CLI, HTTP API, OpenAI-compatible endpoint, MCP server, or Telegram bot.
44

5-
Four ways to unleash it:
5+
Four modes, five interfaces:
66

77
- **Interactive** — drop-in `claude` CLI replacement, persistent container, picks up where you left off
88
- **Programmatic** — pass a prompt, get a response, pipe it into your cursed pipeline
99
- **API server** — HTTP endpoints for prompts, file management, monitoring. Slap it in your infra
10+
- **OpenAI-compatible**`chat/completions` endpoint for LiteLLM, OpenAI SDKs, and anything that speaks OpenAI
11+
- **MCP server** — Model Context Protocol endpoint so other AI agents can use Claude Code as a tool
1012
- **Telegram bot** — talk to Claude from your phone when you're takin' a shit. Per-chat workspaces, models, effort levels, file sharing, shell access
1113

1214
## Table of Contents
@@ -21,6 +23,8 @@ Four ways to unleash it:
2123
- [Interactive mode](#interactive-mode)
2224
- [Programmatic mode](#programmatic-mode)
2325
- [API mode](#api-mode)
26+
- [OpenAI-compatible endpoints](#openai-compatible-endpoints)
27+
- [MCP server](#mcp-server)
2428
- [Telegram mode](#telegram-mode)
2529
- [Customization](#-customization)
2630
- [Gotchas](#-gotchas)
@@ -502,7 +506,7 @@ All file paths are relative to `/workspaces`. Path traversal outside root is blo
502506

503507
#### OpenAI-compatible endpoints
504508

505-
The API also exposes an OpenAI-compatible adapter so tools like [LiteLLM](https://github.com/BerriAI/litellm), OpenAI SDKs, or anything that speaks `chat/completions` can connect directly.
509+
The API also exposes an OpenAI-compatible adapter so tools like [LiteLLM](https://github.com/BerriAI/litellm), OpenAI SDKs, or anything that speaks `chat/completions` can connect directly. Unlike a plain model proxy, this runs the full Claude Code agentic CLI behind the scenes — it can read/write files, run commands, and use tools.
506510

507511
**`GET /openai/v1/models`** — list available models:
508512

@@ -525,14 +529,24 @@ curl -X POST http://localhost:8080/openai/v1/chat/completions \
525529
-d '{"model":"haiku","messages":[{"role":"user","content":"hello"}],"stream":true}'
526530
```
527531

528-
Use the same model aliases as the CLI (`haiku`, `sonnet`, `opus`). `system` role messages become `--system-prompt`. Multiple user/assistant turns are concatenated into a single prompt. Pass `reasoning_effort` (`low`/`medium`/`high`) to control effort — maps to claude's `--effort`. `temperature` and `max_tokens` are accepted but ignored.
532+
Use the same model aliases as the CLI (`haiku`, `sonnet`, `opus`). `system` role messages become `--system-prompt`. Pass `reasoning_effort` (`low`/`medium`/`high`) to control effort — maps to claude's `--effort`. `temperature`, `max_tokens`, `tools`, and other OpenAI-specific fields are accepted but silently ignored. Provider prefixes are stripped automatically (`claude-code/haiku` → `haiku`).
533+
534+
**Message handling:**
535+
- **Single user message** — sent directly as the prompt (fast path, no overhead).
536+
- **Multi-turn conversations** — the full messages array is written to a JSON file in the workspace (`_oai_uploads/conv_<id>.json`). Claude Code reads the file and responds to the last user message, preserving the conversation context.
537+
- **Multimodal content** — base64-encoded images and image URLs in message content are downloaded/decoded and saved to the workspace. The content is replaced with the local file path so Claude Code can read the images directly.
538+
539+
Streaming (`"stream": true`) returns standard SSE events. Content arrives in message-level chunks (not character-by-character deltas) since Claude Code assembles full messages internally.
540+
541+
**File workflow tip:** for best performance, upload input files via `PUT /files/...`, tell Claude Code to work with them by path, then download the output files via `GET /files/...`. Much faster than embedding large content in the prompt.
529542

530543
Custom headers for claude-specific behavior:
531544

532545
| Header | Description |
533546
| ------ | ----------- |
534547
| `X-Claude-Workspace` | Workspace subpath under `/workspaces` |
535548
| `X-Claude-Continue` | Set to `1`/`true`/`yes` to continue the previous session |
549+
| `X-Claude-Append-System-Prompt` | Text to append to the system prompt |
536550

537551
**LiteLLM example:**
538552

@@ -550,19 +564,21 @@ print(response.choices[0].message.content)
550564

551565
#### MCP server
552566

553-
The API also exposes an MCP (Model Context Protocol) server at `/mcp` using streamable HTTP transport. Any MCP-compatible client (Claude Desktop, Claude Code, etc.) can connect to it.
567+
The API also exposes an MCP (Model Context Protocol) server at `/mcp/` using streamable HTTP transport. Any MCP-compatible client (Claude Desktop, Claude Code, etc.) can connect to it. The `claude_run` tool runs the full Claude Code agentic CLI — it can read/write files, run commands, and use tools in the workspace, not just generate text.
554568

555569
```json
556570
{
557571
"mcpServers": {
558572
"claude-code": {
559-
"url": "http://localhost:8080/mcp",
573+
"url": "http://localhost:8080/mcp/",
560574
"headers": { "Authorization": "Bearer your-secret-token" }
561575
}
562576
}
563577
}
564578
```
565579

580+
If your MCP client doesn't support custom headers, pass the token as a query param: `http://localhost:8080/mcp/?apiToken=your-secret-token`
581+
566582
Available tools:
567583

568584
| Tool | Description |

0 commit comments

Comments
 (0)