This section is only for Keywords AI LLM proxy user.

Keywords AI provides a robust and flexible LLM proxy with 250+ LLMs. You can use Keywords AI with OpenAI SDK by just passing the base_url and api_key to the OpenAI SDK.

Integration examples

from openai import OpenAI

client = OpenAI(
    base_url="https://api.keywordsai.co/api/",
    api_key=YOUR_KEYWORDSAI_API_KEY,
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role":"user", "content":"Tell me a long story"}],
)

Supported parameters

OpenAI parameters

We support all the OpenAI parameters. You can pass them directly in the request body.

You can pass Keywords AI parameters in the extra_body parameter.

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
)

Keywords AI parameters

Keywords AI parameters can be passed differently depending on your programming language:

You can pass Keywords AI parameters in the extra_body parameter.

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Tell me a story"}],
    extra_body={"customer_identifier": "test_user_1"}
)

These parameters will take precedence over the OpenAI parameters if they are conflicting.