Groq Quickstart Guide

This guide helps you get started with the Groq API quickly. It covers creating an API key, setting up your environment, and making your first chat completion request using Python.

Key Sections:

  • Getting Started: Links to core documentation sections like Models, Errors, and Changelog.
  • Examples and Demos: Links to practical examples and showcase applications.
  • Features: Overview of key features, including Chat Completions, OpenAI Compatibility, Speech to Text, Tool Use, and Content Moderation.
  • Integrations: Information on Groq Libraries, Vercel AI SDK, LangChain, LlamaIndex, LiteLLM, and Toolhouse integrations.
  • Accounts: Links to API Keys and Rate Limits documentation.
  • Legal: Link to Policies & Notices.
  • Llama 3 Announcement: Highlights the availability of Llama 3.1 models with a link to the blog post.

Quickstart Steps:

  1. Create an API Key:

  2. Set Up Your API Key (Recommended):

    • Enhance security and streamline API usage by setting your API key as an environment variable:
    export GROQ_API_KEY=<your-api-key-here>
  3. Requesting Your First Chat Completion:

    • This section provides code examples for using the Groq API with curl, JavaScript, Python, and JSON.
    • Python Example (using the groq library):
      • Install the Groq Python library:
      pip install groq
      • Perform a Chat Completion:
      import os
      from groq import Groq
       
      client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
       
      chat_completion = client.chat.completions.create(
          messages=[
              {"role": "user", "content": "Explain the importance of fast language models"}
          ],
          model="llama3-8b-8192",
      )
       
      print(chat_completion.choices[0].message.content)

Next Steps:

Key Takeaways:

  • The Groq API provides a simple and efficient way to access powerful language models.
  • Setting up your API key as an environment variable is recommended for security and ease of use.
  • The Python groq library simplifies interaction with the API.
  • Groq offers a vibrant community and resources for learning and collaboration.