anthropics / anthropics/claude-agent-sdk-python

Openrouter is not supported with claude code

Open
#789 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8.1k
Forks
1.3k
Avg merge
2d 31m
Merged PRs (30d)
1

Description

For the past week i've been working on a project, i was able to use openrouter model by configuring claude code but right now its not wokring its thorwing me this error.How do i resolve this?

API Error: 400 {"error":{"message":"No endpoints available that
support Anthropic's context management features (context-management-2025-06-27). Context management requires a
supported provider (Anthropic).","code":400}}

```python
import asyncio
import os
from typing import Any
from dotenv import load_dotenv
from claude_agent_sdk import query, ClaudeAgentOptions, tool, create_sdk_mcp_server

load_dotenv()

@tool(
name="summarize_file",
description="Summarizes the content of a file. Input is a file path, output is a concise summary of the file's content.",
input_schema={"file_path": str},
)
async def summarize_file(args: dict[str, Any]) -> dict[str, Any]:
file_path = args["file_path"]

if not os.path.isfile(file_path):
return {
"content": [{"type": "text", "text": f"Error: File '{file_path}' does not exist."}],
"is_error": True,
}

try:
with open(file_path, "r") as f:
content = f.read()
summary = content[:100] + "..." if len(content) > 100 else content
return {"content": [{"type": "text", "text": summary}]}
except Exception as e:
return {
"content": [{"type": "text", "text": f"Error reading file '{file_path}': {str(e)}"}],
"is_error": True,
}

file_server = create_sdk_mcp_server(name="file_server", tools=[summarize_file])

async def run_agent(user_prompt: str):
options = ClaudeAgentOptions(
setting_sources=["project"],
allowed_tools=["Read", "Write", "Bash", "LS", "Search", "mcp__file_server__*"],
mcp_servers={"file_server": file_server},
model="minimax/minimax-m2.7",
betas=[]
)

async for message in query(prompt=user_prompt, options=options):
print(message)

if __name__ == "__main__":
prompt = "Run the summarize_file tool on main.py"
asyncio.run(run_agent(prompt))

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.