This integration is for the Keywords AI gateway. If you only need to log LLM calls and responses, use the Logging API.
You can use the chat completion endpoint with LangChain’s ChatOpenAI LLM under two lines of code change.
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://api.keywordsai.co/api/",
    api_key="<Your Keywords AI API Key>",
    model="gpt-3.5-turbo",
    streaming=True,
    extra_body={
        "customer_identifier": "customer_11"
    }
)
response = llm.invoke(
    input="Hi"
)
print(response)
In extra_body, you can pass in any OpenAI parameters.To use Keywords AI parameters, you can specify an extra_body object within model_kwargs. In the above example, customer_identifier is the Keywords AI parameter. These parameters will take precedence over the OpenAI parameters if they are conflicting.