This section is only for Keywords AI gateway users.

Pros and Cons

Pros

  • You can use the Thinking feature of Claude 3.7 Sonnet

  • 2 lines of code change to integrate

Cons

  • Can’t call prompts related params with this integration
    • You have to use another integration to use prompts related features
  • Can’t use proxy params like fallback, load_balancing
    • Use another integration to use these features
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.keywordsai.co/api/anthropic/",
    api_key="Your_Keywords_AI_API_Key",
)

message = client.messages.create(
    model="claude-3-opus-20240229",
    max_tokens=1000,
    system="Respond only in Yoda-speak.",
    messages=[
        {"role": "user", "content": "How are you today?"}
    ]
    metadata={
        "keywordsai_params": {
            "customer_identifier": "something" # You need to wrap the customer_identifier into the "keywordsai_params" key
        }
    },
)

print(message.content)

To use Keywords AI parameters, you can pass them in the metadata parameter. In the above example, customer_identifier is a Keywords AI parameter. These parameters will take precedence over the Anthropic parameters if they are conflicting.