xtekky/gpt4free · error · MissingAuthError
API key is required for Puter.js API
Error message
API key is required for Puter.js API
What it means
Raised as MissingAuthError by the Puter provider when create_async_generator is invoked without an api_key. Puter.js requires an explicit key; unlike cookie-based providers it has no HAR/browser fallback, so the call aborts before any request is made.
Source
Thrown at g4f/Provider/needs_auth/Puter.py:415
"temperature",
"presence_penalty",
"top_p",
"frequency_penalty",
"response_format",
"tools",
"parallel_tool_calls",
"tool_choice",
"reasoning_effort",
"logit_bias",
"voice",
"modalities",
"audio",
"prompt_cache_key",
],
**kwargs,
) -> AsyncResult:
if not api_key:
raise MissingAuthError("API key is required for Puter.js API")
# Check if we need to use a vision model
if not model and media is not None and len(media) > 0:
model = cls.default_vision_model
# Check for image URLs in messages
if not model:
for msg in messages:
if msg["role"] == "user":
content = msg.get("content", "")
if isinstance(content, list):
for item in content:
if item.get("type") == "image_url":
model = cls.default_vision_model
break
# Get the model name from the user-provided model
try:View on GitHub (pinned to 973504e177)
Solutions
- Pass api_key when creating the completion: client.chat.completions.create(..., api_key='...')
- Set the key in the provider/client configuration so all calls pick it up
- Obtain a Puter.js API key from the Puter dashboard first if you do not have one
Example fix
# before response = client.chat.completions.create(model='gpt-4o', messages=msgs) # MissingAuthError # after response = client.chat.completions.create(model='gpt-4o', messages=msgs, api_key=os.environ['PUTER_API_KEY'])
Defensive patterns
Strategy: validation
Validate before calling
api_key = os.environ.get('PUTER_API_KEY')
if not api_key:
raise SystemExit('Set PUTER_API_KEY before calling the Puter provider') Type guard
def can_call_puter(api_key: str | None) -> bool:
return isinstance(api_key, str) and api_key.strip() != '' Try / catch
from g4f.errors import MissingAuthError
try:
...create(...)
except MissingAuthError as e:
logging.error('Credentials missing: %s', e) Prevention
- Load provider credentials from env at app startup and fail fast if absent
- Maintain a per-provider credential map so routing never reaches Puter keyless
When it happens
Trigger: Calling the Puter provider (model routed to Puter, or provider=g4f.Provider.Puter) without passing api_key in kwargs, with no api_key stored in the client/provider config.
Common situations: Switching an existing g4f integration to Puter without adding credentials, assuming g4f auto-authenticates all providers, running examples copied from docs that omit the key.
Related errors
- api_key is missing
- Access token is not valid: {cls.request_config.access_token}
- result["error"].get("message", result["error"])
- result
- Unexpected content type: {mime_type}
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/f61c09bd50dd6f45.
Report an issue: GitHub.