{"id":25,"library":"groq","title":"Groq Python SDK","description":"Official Python SDK for GroqCloud API. OpenAI-compatible interface for ultra-low-latency LLM inference on Groq LPU hardware. Model IDs change frequently as models are deprecated and replaced with no versioned aliases.","status":"active","version":"0.18.0","language":"python","source_language":"en","source_url":"https://console.groq.com/docs/overview","tags":["groq","llm","inference","fast","llama","openai-compatible","lpu"],"install":[{"cmd":"pip install groq","lang":"bash","label":"pip"},{"cmd":"uv add groq","lang":"bash","label":"uv"}],"dependencies":[{"reason":"Default HTTP client. Included automatically.","package":"httpx","optional":false},{"reason":"Optional higher-performance async backend. Use DefaultAioHttpClient from groq.","package":"aiohttp","optional":true}],"imports":[{"note":"groq.cloud.core was the original pre-release SDK (v0.3.0, 2024). Completely removed. All current code uses from groq import Groq.","wrong":"from groq.cloud.core import ChatCompletion","symbol":"Groq","correct":"from groq import Groq"},{"note":"Drop-in async version of Groq client. Same interface, use await.","symbol":"AsyncGroq","correct":"from groq import AsyncGroq"},{"note":"Pass as http_client=DefaultAioHttpClient() to AsyncGroq for better concurrency.","symbol":"aiohttp backend","correct":"from groq import DefaultAioHttpClient"}],"quickstart":{"code":"import os\nfrom groq import Groq\n\nclient = Groq(api_key=os.environ['GROQ_API_KEY'])\n\nresponse = client.chat.completions.create(\n    model='llama-3.3-70b-versatile',\n    messages=[{'role': 'user', 'content': 'Hello'}]\n)\nprint(response.choices[0].message.content)","lang":"python","description":"Minimal chat completion"},"warnings":[{"fix":"Replace entire client setup with: from groq import Groq; client = Groq(api_key=...)","message":"groq.cloud.core (pre-release API) is fully removed. ChatCompletion class no longer exists. Any code from early 2024 tutorials is broken.","severity":"breaking","affected_versions":"v0.3.0 and earlier"},{"fix":"Never hardcode model IDs in production. Query https://api.groq.com/openai/v1/models to get current active models. Check https://console.groq.com/docs/deprecations before each release.","message":"Models are deprecated and removed with no versioned aliases. gemma-7b-it and mixtral-8x7b-32768 removed. llama-guard-3-8b decommissioned. Hardcoded model IDs break silently.","severity":"breaking","affected_versions":"all"},{"fix":"Replace max_tokens= with max_completion_tokens= in all chat.completions.create() calls","message":"max_tokens is deprecated in favor of max_completion_tokens. Still works but may be removed.","severity":"breaking","affected_versions":"current"},{"fix":"Migrate function_call pattern to tools=[{type: 'function', function: {...}}] pattern","message":"functions and function_call parameters are deprecated in favor of tools and tool_choice respectively.","severity":"breaking","affected_versions":"all"},{"fix":"Move domain filtering into search_settings={include_domains: [...]} or search_settings={exclude_domains: [...]}","message":"exclude_domains and include_domains parameters deprecated for agentic tooling. Use search_settings parameter instead.","severity":"breaking","affected_versions":"current"},{"fix":"Do not use n > 1. Run multiple requests instead.","message":"n parameter (number of completions) only supports n=1. Passing any other value returns a 400 error.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not rely on these parameters for model behavior control","message":"logprobs, presence_penalty, and frequency_penalty are listed in the API but not supported by any current models. Passing them does not error but has no effect.","severity":"gotcha","affected_versions":"all"},{"fix":"Use only production-tier models. Check model status at console.groq.com/docs/models.","message":"Preview models can be discontinued at short notice. Do not use in production.","severity":"gotcha","affected_versions":"all"},{"fix":"Check current limits at console.groq.com/settings/limits. Implement exponential backoff on groq.RateLimitError.","message":"Rate limits are per-model and vary significantly. Free tier limits are very low. 429s happen frequently in dev without a paid plan.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure the GROQ_API_KEY environment variable is set before running the application, for example, by using `export GROQ_API_KEY='your_api_key'` or by loading from a .env file.","message":"The GROQ_API_KEY environment variable is required for client initialization. Failure to set it results in a KeyError.","severity":"breaking","affected_versions":"all"},{"fix":"Ensure the GROQ_API_KEY environment variable is correctly set in your environment before running the application.","message":"The GROQ_API_KEY environment variable is not set, leading to a KeyError during client initialization.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T04:41:47.000Z","next_check":"2026-03-28T00:00:00.000Z","problems":[{"fix":"Set the `GROQ_API_KEY` environment variable with your actual API key, or pass it directly to the `Groq` client constructor: `import os\nfrom groq import Groq\n\nclient = Groq(api_key=os.environ.get(\"GROQ_API_KEY\"))` or `client = Groq(api_key=\"YOUR_API_KEY\")`.","cause":"The Groq API key is not being provided to the client, either directly in the code or via the `GROQ_API_KEY` environment variable.","error":"groq.GroqError: The api_key client option must be set either by passing api_key to the client or by setting the GROQ_API_KEY environment variable"},{"fix":"Install the `groq` library using pip: `pip install groq`.","cause":"The `groq` Python library has not been installed in your environment or is not accessible within your current Python path.","error":"ModuleNotFoundError: No module named 'groq'"},{"fix":"Verify the exact model ID from the Groq console or documentation and ensure it's still available and that your account has access. For example, use a currently available model like `llama-3.1-8b-instant` or `llama-3.3-70b-versatile`.","cause":"The specified model ID (xxx) is either incorrect, has been deprecated, or your account does not have permissions to access it. Groq model IDs can change frequently.","error":"The model xxx does not exist or you do not have access to it."},{"fix":"Check your internet connection, proxy settings, and ensure there are no firewall rules blocking access to `api.groq.com`. If the issue persists, review SSL certificate configurations or try again later as it might be a temporary network issue.","cause":"The client failed to establish a network connection to the Groq API, possibly due to network issues, a timeout, or an SSL certificate problem.","error":"groq.APIConnectionError: Connection error"},{"fix":"Implement exponential backoff and retry logic in your application. Reduce the frequency of your API calls or consider upgrading your Groq plan for higher rate limits.","cause":"You have exceeded the rate limits imposed by the Groq API for the number of requests you can make within a given timeframe.","error":"groq.APIStatusError: Error code: 429 - {'error': {'message': 'You are sending requests too quickly. Please retry your request later.'}}"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.71,"mem_mb":15.5,"disk_size":"33.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.54,"mem_mb":15.5,"disk_size":"33M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.02,"mem_mb":17.2,"disk_size":"36.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.86,"mem_mb":17.2,"disk_size":"36M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.19,"mem_mb":17.1,"disk_size":"27.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.22,"mem_mb":17.1,"disk_size":"28M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.1,"mem_mb":17.9,"disk_size":"27.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.02,"mem_mb":17.9,"disk_size":"27M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.67,"mem_mb":15.6,"disk_size":"32.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.62,"mem_mb":15.6,"disk_size":"32M"}]},"quickstart_checks":{"last_tested":"2026-05-11","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}