anthropics / anthropics/claude-agent-sdk-python

Openrouter is not supported with claude code

Abierto
#789 1 comentario 3 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
8.1k
Forks
1.3k
Merge medio
2 d 31 min
PR fusionados (30 d)
1

Descripción

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))

```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.