Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gemini-exp-1206 Model Streaming API Call Failure: SSE Connection Timeout and Internal Server Error #4278

Open
p971607 opened this issue Jan 5, 2025 · 1 comment
Labels
ai/provider bug Something isn't working

Comments

@p971607
Copy link

p971607 commented Jan 5, 2025

Description

Experiencing specific model call issues with Gemini API:

Issue Description:

  1. Persistent API call failures when using the gemini-exp-1206 model

  2. Error details:

    {
      "name": "AI_RetryError",
      "cause": undefined,
      "reason": "maxRetriesExceeded",
      "errors": [
        {
          "name": "AI_APICallError",
          "cause": {
            "name": "ConnectTimeoutError",
            "code": "UND_ERR_CONNECT_TIMEOUT",
            "message": "Connect Timeout Error"
          },
          "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-exp-1206:streamGenerateContent?alt=sse",
          "isRetryable": true
        },
        {
          "name": "AI_APICallError",
          "statusCode": 500,
          "responseBody": {
            "error": {
              "code": 500,
              "message": "An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting",
              "status": "INTERNAL"
            }
          },
          "isRetryable": true
        }
      ]
    }
  3. Configuration used:

    {
      "generationConfig": {
        "maxOutputTokens": 8100,
        "temperature": 0.8,
        "topP": 1,
        "responseMimeType": "application/json",
        "responseSchema": {
          "type": "object",
          "required": ["summary", "tasks"],
          "properties": {
            "summary": {
              "type": "string"
            },
            "tasks": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["role", "message"],
                "properties": {
                  "role": { "type": "string" },
                  "message": { "type": "string" }
                }
              }
            }
          }
        }
      },
      "safetySettings": [
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "threshold": "BLOCK_NONE"
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "threshold": "BLOCK_NONE"
        },
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "threshold": "BLOCK_NONE"
        },
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "threshold": "BLOCK_NONE"
        }
      ]
    }

Environment Information:

  1. Same API key works fine with other Gemini models (e.g., gemini-1.5-flash-002)
  2. Using streamObject method from AI library to call API
  3. Model returns same error even with simple prompt testing
  4. Using structured output with JSON schema
  5. All safety settings are set to BLOCK_NONE

Verified Points:

  1. API key is valid (works with other models)
  2. Not caused by complex prompts (fails even with simple prompt tests)
  3. Not a general network connectivity issue (other models work fine)
  4. Not related to safety settings (all set to BLOCK_NONE)
  5. Not related to response schema (fails with simple prompts too)

Code example

import { streamObject } from 'ai';

// Schema definition using zod
const responseSchema = z.object({
summary: z.string().describe('Current stage summary and next steps'),
tasks: z.array(
z.object({
role: z.enum(['ROLE_A', 'ROLE_B', 'ROLE_C']).describe('Role identifier'),
message: z.string().describe('Task description for the role'),
}),
),
});

// API call example
const result = streamObject({
model: 'gemini-exp-1206',
schema: responseSchema,
schemaName: 'StructuredResponse',
schemaDescription: 'Structured response with summary and tasks',
system: 'System prompt content...',
prompt: messages.map((msg) => msg.content).join('\n'),
maxTokens: 8100,
temperature: 0.8,
topP: 1,
responseMimeType: 'application/json',
});

AI provider

"ai": "^4.0.13",

Additional context

No response

@p971607 p971607 added the bug Something isn't working label Jan 5, 2025
@sridvijay
Copy link

sridvijay commented Jan 5, 2025

I'm also experiencing the same thing. (Only on gemini-exp-1206)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/provider bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants