Use Proxy with Anthropic SDK
https://gateway.adaline.ai/v1/anthropic/
import anthropic client = anthropic.Anthropic( api_key="your-anthropic-api-key", base_url="https://gateway.adaline.ai/v1/anthropic/" ) headers = { "adaline-api-key": "your-adaline-api-key", "adaline-project-id": "your-project-id", "adaline-prompt-id": "your-prompt-id" } response = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=1000, messages=[ {"role": "user", "content": "What is artificial intelligence?"} ], extra_headers=headers ) print(response.content[0].text)
import anthropic client = anthropic.Anthropic( api_key="your-anthropic-api-key", base_url="https://gateway.adaline.ai/v1/anthropic/" ) headers = { "adaline-api-key": "your-adaline-api-key", "adaline-project-id": "your-project-id", "adaline-prompt-id": "your-prompt-id" } stream = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=1000, messages=[ {"role": "user", "content": "Explain the theory of relativity in simple terms."} ], stream=True, extra_headers=headers ) for event in stream: if event.type == "content_block_delta": print(event.delta.text, end="")
Was this page helpful?