You can use the chat completion endpoint with LlamaIndex’s OpenAI LLM under two lines of code change.

Python
from llama_index.llms.openai import OpenAI as KeywordsClient

env = environment["production"]

keywords_ai = KeywordsClient(
    api_base="https://api.keywordsai.co/api/",
    api_key=env["api_key"],
    model="gpt-3.5-turbo"
)

response = keywords_ai.complete(
    "Hello",
    extra_body={"customer_identifier": "customer_11"}
)

print(response)

In complete method, you can pass in any OpenAI parameters.

To use Keywords AI parameters, add extra_body argument and specify the value in a dictionary. In the above example, customer_identifier is the Keywords AI parameter. These parameters will take precedence over the OpenAI parameters if they are conflicting.