claude-code-adapter-fastapi CLAUDE.md

A FastAPI service that converts Claude Code tool definitions into prompts for models that do not natively understand those tools.

In plain words
What is it for?
It helps run, test, lint, format, configure, and containerize an adapter with health and message endpoints.
Why use it?
It lets Anthropic style requests pass through to endpoints that use the OpenAI compatible API format.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/wangfumin1/claude-code-adapter-fastapi/claude-md
Clone the repo
git clone --depth 1 https://github.com/wangfumin1/claude-code-adapter-fastapi
Per session 638 This file is loaded in full into every session.
When invoked 638 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00638 $0.00638
Opus 5 $0.00319 $0.00319
Sonnet 5 $0.00128 $0.00128
Haiku 4.5 $0.00064 $0.00064

Measured 2d ago against content hash 0c7be8fc0fc2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

claude-code-adapter-fastapi CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

This is a Claude Code Adapter built with FastAPI that converts Claude Code tool definitions into system prompts, allowing non-native tool models to understand and use tools. The adapter acts as a proxy between Anthropic-style API requests and OpenAI-compatible endpoints.

Development Commands

Basic Commands

  • make run - Start development server with hot reload
  • make run-prod - Run production server
  • make test - Run tests
  • make lint - Run code linting (flake8 + mypy)
  • make format - Format code (black + isort)

Environment Setup

  • make setup - Create virtual environment
  • make install - Install production dependencies
  • make install-dev - Install development dependencies
  • make check-env - Check environment configuration

Docker Commands

  • make docker-build - Build Docker image
  • make docker-run - Run Docker container
  • make docker-compose-up - Start with docker-compose

Architecture

Core Components

  • app.py - FastAPI application with main endpoints (/health, /v1/messages)
  • services.py - Business logic layer (message conversion, OpenAI client, response processing)
  • models.py - Pydantic data models for API requests/responses
  • config.py - Configuration management with YAML and environment variable support
  • utils.py - Utility functions for tool parsing and content processing

Key Features

  • Tool Prompt Adaptation: Converts tool definitions into system prompts for non-native models
  • Message Format Conversion: Translates between Anthropic and OpenAI message formats
  • Tool Selection: Dynamic tool selection based on conversation context
  • Streaming Support: Full support for streaming responses
  • Flexible Configuration: YAML config files with environment variable overrides

Project Structure

src/claude_code_adapter/
├── app.py          # FastAPI application and endpoints
├── config.py       # Configuration management
├── models.py       # Pydantic data models
├── services.py     # Business logic services
└── utils.py        # Utility functions

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 74 lines · 638 tokens per session scan A 0c7be8fc0fc2

Subscribe to this mod's changes

claude-code-adapter-fastapi CLAUDE.md is an instructions file published in the GitHub repository wangfumin1/claude-code-adapter-fastapi (5 stars, last pushed 22d ago), licensed MIT. It adds 638 tokens to every session, about $0.0032 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.