RealComposer

Anthropic Safe & Unsafe Practices

Direct Answer

Anthropic API keys (sk-ant-) are server-only. The SDK only allows browser calls when you opt in with a dangerous direct browser access flag, which exposes the key to visitors. Route Claude calls through a server or edge proxy with workspace spend limits.

Credentials & Where They Belong

Server only
API key (sk-ant-)

Bills usage to your workspace. Create one per environment.

Safe Practices

  • Use workspaces with spend limits

    Isolate production and testing keys and cap monthly spend per workspace.

  • Pin model and max_tokens server-side

    Never accept model or token limits from the client request body.

Unsafe Practices

  • Enabling direct browser access in production

    The flag exists for prototypes. In production it publishes your key to every visitor.

  • Passing unbounded conversation history from the client

    Attackers can send huge contexts to inflate cost. Trim and cap on the server.

The RealComposer Pattern

Keep ANTHROPIC_API_KEY in the vault and expose a fixed-model pipeline that returns only the text content block your UI renders.

START BUILDING FREE

Frequently Asked Questions

Q:Is the anthropic-dangerous-direct-browser-access header safe?

Only for local prototypes with your own key. Production apps should proxy requests so the key never reaches the browser.

Anthropic Recipes

Security & Secret Vault

Secure Anthropic Claude API Proxy for Frontend

To solve secure anthropic claude api proxy for frontend, never execute unauthenticated requests or embed private tokens directly in client bundles. RealComposer acts as a sub-10ms edge gateway running on Cloudflare Workers that securely injects credentials from your Secret Vault, normalizes responses, and prevents unauthorized API usage. Route calls through your RealComposer edge URL to guarantee complete privacy, robust origin validation, and low mobile latency.

Sub-10ms edgeView Recipe

Related Concepts