[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [AI SDK](/c/ai-sdk/62) # GatewayInternalServerError With Gemini & Grok Models 134 views · 0 likes · 2 posts ashlooz (@ashwinprabou) · 2025-12-14 I've been running some models via AI-Gateway and am running into the following errors: - 400 for xai/grok-4-fast-reasoning - 401 for google/gemini-2.5-flash-lite My other models (claude/claude-3-5-sonnet-20241022, meta/llama-3.1-8b, openai/gpt-4o) all work fine, and I'm passing the exact same stuff through all of them. What could be the issue? Gemini Complete Log: ``` AI Gateway error: Error [GatewayInternalServerError]: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. at async E (.next/server/chunks/[root-of-the-server]__642d5f6a._.js:44:206) { statusCode: 401, type: 'internal_server_error', [cause]: Error [AI_APICallError]: [object Object] at ignore-listed frames { cause: undefined, url: 'https://ai-gateway.vercel.sh/v1/ai/language-model', requestBodyValues: { maxOutputTokens: undefined, temperature: 0.8, topP: undefined, topK: undefined, presencePenalty: undefined, frequencyPenalty: undefined, stopSequences: undefined, seed: undefined, tools: undefined, toolChoice: undefined, responseFormat: undefined, prompt: [Array], providerOptions: undefined, headers: [Object] }, statusCode: 401, responseHeaders: { 'cache-control': 'public, max-age=0, must-revalidate', 'content-type': 'application/json', date: 'Sun, 14 Dec 2025 21:16:34 GMT', server: 'Vercel', 'strict-transport-security': 'max-age=63072000; includeSubDomains; preload', 'transfer-encoding': 'chunked', vary: 'rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch', 'x-matched-path': '/v1/ai/language-model', 'x-vercel-cache': 'MISS', 'x-vercel-id': 'sfo1:iad1::iad1::8zlhk-1765746994202-fac38fd6c188' }, responseBody: '{"error":{"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","type":"AI_APICallError","param":{"error":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","statusCode":401,"name":"AI_APICallError","message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","url":"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent","isRetryable":false,"type":"AI_APICallError"}}}', isRetryable: false, data: { error: [Object] } } } ``` Grok Complete Log: ``` 2025-12-14 21:16:49.958 [info] [AI Gateway] Calling model: xai/grok-4-fast-reasoning Environment: production 2025-12-14 21:16:50.036 [error] AI Gateway error: Error [GatewayInternalServerError]: Bad Request at async E (.next/server/chunks/[root-of-the-server]__642d5f6a._.js:44:206) { statusCode: 400, type: 'internal_server_error', [cause]: Error [AI_APICallError]: [object Object] at ignore-listed frames { cause: undefined, url: 'https://ai-gateway.vercel.sh/v1/ai/language-model', requestBodyValues: { maxOutputTokens: undefined, temperature: 0.8, topP: undefined, topK: undefined, presencePenalty: undefined, frequencyPenalty: undefined, stopSequences: undefined, seed: undefined, tools: undefined, toolChoice: undefined, responseFormat: undefined, prompt: [Array], providerOptions: undefined, headers: [Object] }, statusCode: 400, responseHeaders: { 'cache-control': 'public, max-age=0, must-revalidate', 'content-type': 'application/json', date: 'Sun, 14 Dec 2025 21:16:50 GMT', server: 'Vercel', 'strict-transport-security': 'max-age=63072000; includeSubDomains; preload', 'transfer-encoding': 'chunked', vary: 'rsc, next-router-state-tree, next-router-prefetch, next-router-segment-prefetch', 'x-matched-path': '/v1/ai/language-model', 'x-vercel-cache': 'MISS', 'x-vercel-id': 'sfo1:iad1::iad1::8vhdd-1765747009969-a0ff312fc70d' }, responseBody: '{"error":{"message":"Bad Request","type":"AI_APICallError","param":{"error":"Bad Request","statusCode":400,"name":"AI_APICallError","message":"Bad Request","url":"https://api.x.ai/v1/chat/completions","isRetryable":false,"type":"AI_APICallError"}}}', isRetryable: false, data: { error: [Object] } } }``` Walter Korman (@shaper) · 2025-12-26 Hi there, the Google request is an auth failure – are you using BYOK? Are you able to submit requests of other models or are all Gemini models failing auth? On the x.ai request, can you provide a sample code snippet that produces the issue, since it reads as if it is specific to the prompt/params of the request, so we can help investigate and diagnose?