When attempting to use the Vercel AI Gateway Chat Completions endpoint with the openai Python SDK, requests are failing with a 403 RestrictedModelsError. The error message states that free credits temporarily have restricted access due to abuse.
Running a Python script that sends a base64 image to the AI Gateway results in an immediate crash. The API returns a 403 status code with the following JSON error and provider metadata:
Error:
{ "error": { "message": "Free credits temporarily have restricted access due to abuse. We are working on a resolution. Paid credits continue to have unrestricted access.", "type": "no_providers_available", "param": { "statusCode": 403, "name": "RestrictedModelsError" } }, "providerMetadata": { "gateway": { "routing": { "originalModelId": "google/gemini-3-flash", "resolvedProvider": "vertex", "resolvedProviderApiModelId": "gemini-3-flash-preview" } } }}Expected Behavior
The AI Gateway should successfully route the prompt and image payload to the requested model (e.g., google/gemini-3-flash or other compatible vision models), process the completion, and return the generated text response without blocking the request.
Steps to Reproduce
- Configure the
openaiPython SDK to use the Vercel AI Gateway base URL (https://ai-gateway.vercel.sh/v1). - Authenticate using a Vercel AI Gateway API key on a free tier (Hobby) account.
- Call the
client.chat.completions.createendpoint, passing a system prompt and a base64-encoded image URL. - Execute the script and observe the
403error response.
Code Configuration
Here is the isolated function (from my script) used to make the API call:
from openai import OpenAI
def get_ai_filename(base64_img, gateway_url, api_key, model_name): client = OpenAI( api_key=api_key, base_url=gateway_url # https://ai-gateway.vercel.sh/v1 ) prompt = "Describe this image in 2 to 5 words to be used as a filename." completion = client.chat.completions.create( model=model_name, # User input: google/gemini-3-flash messages=[ { "role": "user", "content": [ {"type": "text", "text": prompt}, { "type": "image_url", "image_url": { "url": f"data:image/jpeg;base64,{base64_img}", "detail": "auto" } } ] } ], max_tokens=30, temperature=0.3, stream=False ) return completion.choices[0].message.content.strip()Environment
Below are my environment details (I’m running this in a Codespace).
==================================================ENVIRONMENT DETAILS REPORTGenerated on: 2026-04-13 13:38:26==================================================
--- SYSTEM INFO ---Os : LinuxOs Release : 6.8.0-1044-azureOs Version : #50~22.04.1-Ubuntu SMP Wed Dec 3 15:13:22 UTC 2025Machine Architecture : x86_64Processor : x86_64Node Name : [REDACTED - NO PII]
--- PYTHON INFO ---Version : 3.12.1 (main, Nov 27 2025, 10:47:52) [GCC 13.3.0]Executable Path : /home/codespace/.python/current/bin/pythonCompiler : GCC 13.3.0Build : ('main', 'Nov 27 2025 10:47:52')
--- NETWORK INFO ---Hostname : [REDACTED - NO PII]Local Ip : [REDACTED - NO PII]
--- ENVIRONMENT VARIABLES ---Not included by user choice.