| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This directory contains examples demonstrating how to use the OpenAI-compatible API with Claude's thinking blocks feature through the proxy server.
Thinking blocks are a special feature in Claude that captures the AI's reasoning process. They are formatted as:
<thinking signature="cryptographic_signature">
The AI's internal reasoning process...
</thinking>The proxy server preserves these blocks in multi-turn conversations, allowing you to:
Install dependencies:
pip install openaiSet your API key:
export ANTHROPIC_API_KEY="your-anthropic-api-key"Start the proxy server:
uv run python main.pyA minimal example showing basic thinking block functionality:
python examples/simple_thinking_demo.pyFeatures:
Comprehensive examples with multiple scenarios:
python examples/openai_thinking_demo.pyFeatures:
Shows how to get structured JSON responses:
python examples/openai_structured_response_demo.pyThe proxy automatically maps OpenAI models to Claude models with thinking enabled:
import re
# Pattern to match thinking blocks
thinking_pattern = r'<thinking signature="([^"]*)">(.*?)</thinking>'
matches = re.findall(thinking_pattern, content, re.DOTALL)
# Remove thinking blocks to get visible content
visible_content = re.sub(thinking_pattern, '', content, flags=re.DOTALL)Always include the full content (with thinking blocks) in the conversation history:
messages = [
{"role": "user", "content": "First question"},
{"role": "assistant", "content": full_response_with_thinking}, # Important!
{"role": "user", "content": "Follow-up question"}
]If you get connection errors:
If thinking blocks don't appear:
| Back | FazBrowse Home | New Git URL |