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

# Generate Content

Gemini-compatible generateContent API on PipeLLM

## Endpoint

```text theme={null}
POST https://api.portix.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.
</Note>

## Install SDK

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

## Code Examples

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.portix.ai/v1beta/models/gemini-3-flash-preview:generateContent" \
      -H "Content-Type: application/json" \
      -H "x-goog-api-key: $YOUR_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('YOUR_API_KEY'),
      http_options={'base_url': 'https://api.portix.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.YOUR_API_KEY,
      httpOptions: {
        baseUrl: 'https://api.portix.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("YOUR_API_KEY")),
        option.WithEndpoint("https://api.portix.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
  }
}
```
