> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inference.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Groq

> Route Groq requests through Inference Catalyst for full observability.

Route your Groq requests through the Inference Catalyst gateway to get cost tracking, latency monitoring, and analytics. Groq is OpenAI-compatible, so you use the OpenAI SDK with the `x-inference-provider-url` header to specify Groq's base URL.

<Info>Prefer automatic setup? Run `inf instrument` to instrument your codebase in seconds. [Learn more](/integrations/install-with-ai)</Info>

## Setup

<Steps>
  <Step title="Get your API keys">
    You need two keys:

    * **Inference Catalyst project API key** — from your [dashboard](https://inference.net/dashboard) under **API Keys**
    * **Groq API key** — from your [Groq console](https://console.groq.com/keys)
  </Step>

  <Step title="Set environment variables">
    <Metadata text="integrations/groq/env-vars" />

    ```bash theme={"system"}
    export INFERENCE_API_KEY=<your-project-api-key>
    export GROQ_API_KEY=<your-groq-api-key>
    ```
  </Step>

  <Step title="Update your code">
    Point the SDK at the gateway. Your project API key goes in `apiKey`, and the `x-inference-provider-url` header tells the gateway to forward requests to Groq.

    <CodeGroup>
      <Metadata text="integrations/groq/setup" />

      ```typescript TypeScript theme={"system"}
      import OpenAI from "openai";

      const client = new OpenAI({
        baseURL: "https://api.inference.net/v1",
        apiKey: process.env.INFERENCE_API_KEY,
        defaultHeaders: {
          "x-inference-provider-api-key": process.env.GROQ_API_KEY,
          "x-inference-provider-url": "https://api.groq.com/openai/v1",
          "x-inference-environment": process.env.NODE_ENV,
        },
      });

      const response = await client.chat.completions.create({
        model: "llama-3.3-70b-versatile",
        messages: [{ role: "user", content: "Hello" }],
      }, {
        headers: { "x-inference-task-id": "default" },
      });
      ```

      <Metadata text="integrations/groq/setup" />

      ```python Python theme={"system"}
      import os
      from openai import OpenAI

      client = OpenAI(
          base_url="https://api.inference.net/v1",
          api_key=os.environ["INFERENCE_API_KEY"],
          default_headers={
              "x-inference-provider-api-key": os.environ["GROQ_API_KEY"],
              "x-inference-provider-url": "https://api.groq.com/openai/v1",
              "x-inference-environment": env = os.getenv("APP_ENV", "development"),
          },
      )

      response = client.chat.completions.create(
          model="llama-3.3-70b-versatile",
          messages=[{"role": "user", "content": "Hello"}],
          extra_headers={"x-inference-task-id": "default"},
      )
      ```

      <Metadata text="integrations/groq/setup-curl" />

      ```bash cURL theme={"system"}
      curl https://api.inference.net/v1/chat/completions \
        -H "Authorization: Bearer $INFERENCE_API_KEY" \
        -H "x-inference-provider-api-key: $GROQ_API_KEY" \
        -H "Content-Type: application/json" \
        -H "x-inference-provider-url: https://api.groq.com/openai/v1" \
        -H "x-inference-environment: production" \
        -H "x-inference-task-id: default" \
        -d '{
          "model": "llama-3.3-70b-versatile",
          "messages": [{"role": "user", "content": "Hello"}]
        }'
      ```
    </CodeGroup>
  </Step>
</Steps>
