{"record":{"id":"5d9f8c7a3280712d","repo":"xtekky/gpt4free","slug":"add-a-api-key-5d9f8c","errorCode":null,"errorMessage":"Add a \"api_key\"","messagePattern":"Add a \"api_key\"","errorType":"exception","errorClass":"MissingAuthError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/template/OpenaiTemplate.py","lineNumber":226,"sourceCode":"            \"logit_bias\",\n            \"modalities\",\n            \"audio\",\n            \"stream_options\",\n            \"include_reasoning\",\n            \"response_format\",\n            \"max_completion_tokens\",\n            \"reasoning_effort\",\n            \"search_settings\",\n            \"prompt_cache_key\",\n        ],\n        extra_body: dict = None,\n        yield_request: bool = True,\n        **kwargs,\n    ) -> AsyncResult:\n        if api_key is None and cls.api_key is not None:\n            api_key = cls.api_key\n        if cls.needs_auth and api_key is None:\n            raise MissingAuthError('Add a \"api_key\"')\n        async with StreamSession(\n            proxy=proxy,\n            headers=cls.get_headers(stream, api_key, headers),\n            timeout=timeout,\n            impersonate=impersonate,\n        ) as session:\n            model = cls.get_model(model, api_key=api_key, base_url=base_url)\n            if base_url is None:\n                base_url = (\n                    cls.base_url if cls.is_provider_api_key(api_key) else cls.backup_url\n                )\n\n            # Proxy for image generation feature\n            if model and model in cls.image_models or prompt:\n                prompt = format_media_prompt(messages, prompt)\n                size = use_aspect_ratio(\n                    {\"width\": kwargs.get(\"width\"), \"height\": kwargs.get(\"height\")},\n                    kwargs.get(\"aspect_ratio\", None),","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/template/OpenaiTemplate.py#L208-L244","documentation":"Error \"Add a \"api_key\"\" thrown in xtekky/gpt4free.","triggerScenarios":"Thrown at g4f/Provider/template/OpenaiTemplate.py:226 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an api_key argument to the provider call.","Set the provider's API key environment variable before calling."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}