Keywords AI allows you to call 200+ LLMs with a single OpenAI compatible format. You can switch between models with only 1 line of code change.

1

Create an API key

To create an API key, visit the API key page

2

Copy the code from the code box

After you create an API key, click on the View code button to copy the code into your codebase.

3

Choose the best model in Models page

Go to the Models page and choose the best model for your use case. Click the Copy button to copy the model id.

Call models with OpenAI SDK

Call models with a standard API call

  • URL change: Modify the API endpoint URL in your code from OpenAI’s URL to the Keywords AI endpoint URL: https://keywordsai.co/api/chat/completions.
  • API key: Replace the OpenAI API key with your Keywords AI API key.
  • Parameters: See supported parameters in the API reference.

Response

The results should be printed in the console.

{
  "id": "chatcmpl-8Ygj0WAGNhHBFjatPCefcPeNi12ct",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": { "content": "Hello World", "role": "assistant" }
    }
  ],
  "created": 1703230636,
  "model": "gpt-3.5-turbo",
  "object": "chat.completion",
  "system_fingerprint": null,
  "usage": { "completion_tokens": 2, "prompt_tokens": 12, "total_tokens": 14 },
  "_response_ms": 653.2679999999999
}