3a58fba521
OpenAI-compatible FastAPI server wrapping the Claude Code CLI. Translates /v1/chat/completions requests into claude --print subprocess calls using stream-json input/output for multi-turn support and real streaming deltas. Features: - Full multi-turn conversation support via --input-format stream-json - Real-time streaming with --include-partial-messages delta tracking - Rate limit (429) and auth error (401) detection from CLI stderr - Configurable timeout, graceful subprocess cleanup on disconnect - /v1/models endpoint and /health check
14 lines
371 B
Docker
14 lines
371 B
Docker
FROM python:3.12-slim
|
|
|
|
RUN pip install --no-cache-dir fastapi "uvicorn[standard]"
|
|
|
|
COPY server.py /app/server.py
|
|
WORKDIR /app
|
|
|
|
# claude binary and ~/.claude config dir are bind-mounted at runtime:
|
|
# -v /usr/local/bin/claude:/usr/local/bin/claude:ro
|
|
# -v /root/.claude:/root/.claude:ro
|
|
|
|
EXPOSE 8000
|
|
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
|