Skip to main content

Groq models compatibility

Add Groq API keys

There are 2 ways to add your OpenRouter credentials to your requests:

Via UI

1

Go to the Providers page

2

Add your Groq credentials.

Dashboard Page

Via code

  • Add customer_credentials parameter in your request body to use your own Groq credits.
{
  // Rest of the request body
  "customer_credentials": {
    "groq": {
      "api_key": "YOUR_GROQ_API_KEY",
    }
  }
}

Override credentials for a particular model. (Optional)

One-off credential overrides. Instead of using what is uploaded for each provider, this targets credentials for individual models.
{
  // Rest of the request body
  "customer_credentials": {
    "groq": {
      "api_key": "YOUR_GROQ_API_KEY"
    }
  },
  "credential_override": {
    "groq/llama-3.1-8b-versatile":{ // override for a specific model.
      "api_key": "ANOTHER_GROQ_API_KEY"
    }
  }
}

Full request example

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",
    messages=[{"role":"user", "content":"Tell me a long story"}],
    extra_body={"customer_credentials": {
                  "groq": {
                      "api_key": "YOUR_GROQ_API_KEY",
                  }
                }
              }
)
```python api_example.py
import requests
def demo_call(input, 
              model="gpt-4o",
              token="YOUR_KEYWORDS_AI_API_KEY"
              ):
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {token}',
    }

    data = {
        'model': model,
        'messages': [{'role': 'user', 'content': input}],
        'customer_credentials': {
            'groq': {
                'api_key': "YOUR_GROQ_API_KEY",
            }
        }
    }

    response = requests.post('https://api.keywordsai.co/api/chat/completions', headers=headers, json=data)
    return response

messages = "Say 'Hello World'"
print(demo_call(messages).json())
I