groq-python  by groq

Python SDK for the Groq API

Created 1 year ago
548 stars

Top 58.3% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

This Python library provides convenient access to the Groq REST API for developers building applications with LLMs. It offers both synchronous and asynchronous clients, type-hinted requests and responses for improved developer experience, and robust error handling.

How It Works

The library leverages httpx for both synchronous and asynchronous HTTP requests, ensuring efficient and modern network communication. It's generated using Stainless, which likely contributes to its comprehensive type definitions (using TypedDict for requests and Pydantic models for responses). This approach enhances code maintainability, enables editor autocompletion, and aids in early bug detection through type checking.

Quick Start & Requirements

  • Install from PyPI: pip install groq
  • Requirements: Python 3.8+
  • API Key: Required, recommended to manage via environment variables (GROQ_API_KEY) or .env files.
  • Documentation: console.groq.com, api.md

Highlighted Details

  • Supports both synchronous and asynchronous API interactions.
  • Responses are Pydantic models with methods for serialization (to_json, to_dict).
  • File uploads handled via bytes, PathLike, or (filename, contents, media type) tuples.
  • Automatic retries for connection errors, timeouts, and server errors (configurable).
  • Configurable timeouts and advanced logging via GROQ_LOG environment variable.
  • Ability to access raw response data and stream responses.
  • Supports making requests to undocumented endpoints and passing undocumented parameters.

Maintenance & Community

  • Follows SemVer conventions with a commitment to backward compatibility.
  • Open to feedback and contributions via GitHub issues.

Licensing & Compatibility

  • License: Not explicitly stated in the README.
  • Compatibility: Designed for Python 3.8+.

Limitations & Caveats

The README does not specify the license, which is crucial for commercial use or closed-source integration. While it mentions SemVer, it notes that some backward-incompatible changes might be released as minor versions, requiring user vigilance.

Health Check
Last Commit

1 day ago

Responsiveness

Inactive

Pull Requests (30d)
2
Issues (30d)
0
Star History
9 stars in the last 30 days

Explore Similar Projects

Starred by Adam Wolff Adam Wolff(Claude Code Core; MTS at Anthropic), Samuel Colvin Samuel Colvin(Founder and Author of Pydantic), and
5 more.

anthropic-sdk-python by anthropics

0.5%
2k
Python SDK for Anthropic's REST API
Created 2 years ago
Updated 1 day ago
Feedback? Help us improve.