Create an API Key

Please visit here to create an API Key.

Configure your API key as an environment variable. This approach streamlines your API usage by eliminating the need to include your API key in each request. Moreover, it enhances security by minimizing the risk of inadvertently including your API key in your codebase.

In your terminal of choice:

export GROQ_API_KEY=<your-api-key-here>

Requesting your first chat completion

Execute this curl command in the terminal of your choice:

curl -X POST "https://api.groq.com/openai/v1/chat/completions" \
 -H "Authorization: Bearer $GROQ_API_KEY" \
 -H "Content-Type: application/json" \
 -d '{"messages": [{"role": "user", "content": "Explain the importance of fast language models"}], "model": "llama3-8b-8192"}'

Next Steps

  • Check out the Playground to try out the Groq API in your browser
  • Join our GroqCloud developer community on Discord
  • Chat with our Docs at lightning speed using the Groq API!
  • Add a how-to on your project to the Groq API Cookbook