> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipellm.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Content

> Gemini-compatible generateContent API on PipeLLM

For authentication and model list, see [Overview](/api-reference/gemini/overview).

## Endpoint

```
POST https://api.pipellm.ai/v1beta/models/{model}:generateContent
```

<Note>
  This free route accepts Gemini native requests and routes only to Gemini
  platforms. To keep the Gemini format while calling OpenAI or Anthropic
  models, use the [Gemini Format Converter](/converter/gemini-format).
</Note>

## Install SDK

```bash theme={null}
pip install google-genai
```

## Code Examples

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.pipellm.ai/v1beta/models/gemini-3-flash-preview:generateContent" \
      -H "Content-Type: application/json" \
      -H "x-goog-api-key: $PIPELLM_API_KEY" \
      -d '{
        "contents": [
          {
            "role": "user",
            "parts": [
              {"text": "Why is the sky blue?"}
            ]
          }
        ]
      }'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import os
    from google import genai

    client = genai.Client(
      api_key=os.getenv('PIPELLM_API_KEY'),
      http_options={'base_url': 'https://api.pipellm.ai'}
    )

    response = client.models.generate_content(
      model='gemini-3-flash-preview',
      contents='Why is the sky blue?'
    )

    print(response.text)
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    import { GoogleGenAI } from '@google/genai';

    const ai = new GoogleGenAI({
      apiKey: process.env.PIPELLM_API_KEY,
      httpOptions: {
        baseUrl: 'https://api.pipellm.ai'
      }
    });

    const response = await ai.models.generateContent({
      model: 'gemini-3-flash-preview',
      contents: 'Why is the sky blue?'
    });

    console.log(response.text);
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    package main

    import (
      "context"
      "os"
      "github.com/google/generative-ai-go/genai"
      "google.golang.org/api/option"
    )

    func main() {
      ctx := context.Background()
      client, _ := genai.NewClient(ctx,
        option.WithAPIKey(os.Getenv("PIPELLM_API_KEY")),
        option.WithEndpoint("https://api.pipellm.ai"),
      )
      defer client.Close()

      model := client.GenerativeModel("gemini-3-flash-preview")
      resp, _ := model.GenerateContent(ctx,
        genai.Text("Why is the sky blue?"),
      )
    }
    ```
  </Tab>
</Tabs>

## Request Format

```json theme={null}
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {"text": "Your message here"}
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "maxOutputTokens": 1024
  }
}
```

## Response Format

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "parts": [
          {"text": "The sky appears blue because..."}
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 10,
    "candidatesTokenCount": 50,
    "totalTokenCount": 60
  }
}
```

## Related Docs

<Columns cols={3}>
  <Card title="Routing & Protocols" icon="route" href="/guides/routing-protocols">
    Native-route constraints and converter routes
  </Card>

  <Card title="Gemini Overview" icon="sparkles" href="/api-reference/gemini/overview">
    Headers, models, and route family overview
  </Card>

  <Card title="Gemini Format Converter" icon="shuffle" href="/converter/gemini-format">
    Keep Gemini format while calling other providers
  </Card>
</Columns>
