Cloudflare Docs
AI Gateway
Edit this page on GitHub
Set theme to dark (⇧+D)

Groq

https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_slug}/groq

When making requests to Groq, replace https://api.groq.com/openai/v1 in the URL you’re currently using with https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_slug}/groq.

Example fetch request
curl -X POST https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_slug}/groq/chat/completions \
--header 'Authorization: Bearer {groq_api_key}' \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": "What is Cloudflare?"
}
],
"model": "mixtral-8x7b-32768"
}'

If using the groq-sdk, set your endpoint like this:

index.js
import Groq from 'groq-sdk';
const groq = new Groq({
apiKey: env.GROQ_API_KEY,
baseURL: "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_slug}/groq"
});
const chatCompletion = await groq.chat.completions.create({
messages: [{ role: 'user', content: 'What is Cloudflare?' }],
model: 'mixtral-8x7b-32768',
});