How it works
Anthropic uses direct mode. Because Anthropic’s API is not OpenAI-compatible, Cognisafe wraps themessages.create method on the Anthropic client rather than routing through the proxy. After the model responds:
- Your code receives the response immediately
- The SDK fires a background task that ships the request and response payload to
POST /internal/logon the FastAPI backend - The backend queues a scoring job in Redis
Installation
Setup
Supported capabilities
Scoring note
Safety scoring always uses the model configured viaSCORER_MODEL (default: gpt-4o-mini), regardless of which Claude model was used for the original call. The scorers are model-agnostic — they receive the text of the prompt and response, not a reference to the originating model.
Claude models and the scoring model are completely independent. You can use
claude-opus-4-5 for your product and GPT-4o mini as the safety scorer with no conflict.Async client
patch_anthropic() also wraps the async client:

