{"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,"search_vec":"'alias':38 'api':9 'chang':27 'compat':12,46 'deprec':32 'fast':42 'frequent':28 'groq':1,22,39 'groqcloud':8 'hardwar':24 'id':26 'infer':20,41 'interfac':13 'latenc':18 'llama':43 'llm':19,40 'low':17 'lpu':23,47 'model':25,30 'offici':4 'openai':11,45 'openai-compat':10,44 'python':2,5 'replac':34 'sdk':3,6 'ultra':16 'ultra-low-lat':15 'version':37","created_at":"2026-03-16T04:39:09.011572+00:00","updated_at":"2026-04-16T15:29:03.052728+00:00","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,"quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"1.4.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://groq.com","github":"https://github.com/groq/groq-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/groq/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-27","last_verified":"2026-06-27","next_check":"2026-07-27","install_tag":"verified"}}