← All AI API providers

DEVELOPER FIELD NOTES / DOCS CHECKED 2026-09-23

Groq
API endpoint & setup.

Keep /openai/v1 in the base URL. OpenAI compatibility does not mean every OpenAI parameter is supported; check the compatibility notes.

SDK base URL

https://api.groq.com/openai/v1

Full request endpoint · POST

https://api.groq.com/openai/v1/chat/completions

Read the official Groq documentation ↗ · Checked 2026-09-23; no live API call made.

A small starting point.

Install the library shown below. Set AI_MODEL to a model available to your account and GROQ_API_KEY to your key. In cURL, replace YOUR_MODEL_ID. Replace any workspace placeholders before running.

Python

# pip install openai
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GROQ_API_KEY"],
    base_url="https://api.groq.com/openai/v1",
)
response = client.chat.completions.create(
    model=os.environ["AI_MODEL"], messages=[{"role": "user", "content": "Hello!"}]
)
print(response)

Node.js

// npm install openai
// Server-side Node.js; never expose API keys in a browser.
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.GROQ_API_KEY,
  baseURL: "https://api.groq.com/openai/v1",
});
const response = await client.chat.completions.create({
  "model": process.env.AI_MODEL,
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
});
console.log(response);

cURL

curl 'https://api.groq.com/openai/v1/chat/completions' \
  -H "Authorization: Bearer $GROQ_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "YOUR_MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}'

Before moving this into production.

Check model availability, billing, rate limits and supported parameters in the provider documentation. Start with a small request from your backend. Keep keys out of client-side JavaScript and source control.

These examples show the request shape and configuration. They do not test your credentials or guarantee access to a model.

Compare other AI API endpoints →