Claude Agent SDK (Python) on Redline

The Python Claude Agent SDK also drives the Claude Code binary, so it reads the same Anthropic environment variables. Pass them through ClaudeAgentOptions, which merges on top of the inherited environment.

Pass env through ClaudeAgentOptions

# pip install claude-agent-sdk
import os, anyio
from claude_agent_sdk import query, ClaudeAgentOptions

options = ClaudeAgentOptions(env={
    "ANTHROPIC_BASE_URL": "https://redline-gateway.pages.dev",
    "ANTHROPIC_AUTH_TOKEN": os.environ["REDLINE_API_KEY"],
    "ANTHROPIC_MODEL": "deepseek/deepseek-chat-v3.1",
})

async def main():
    async for message in query(prompt="List the files", options=options):
        print(message)

anyio.run(main)

The model must support tool calling for the agent to edit files or run commands. See the model list for which ones do.

Related guides