# Gemini Style

Use Gemini generateContent and streamGenerateContent

SilentAPI provides endpoints compatible with the Gemini API under `/v1beta`. Point the Google GenAI SDK at SilentAPI and send your API key.

## Endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/v1beta/models/{model}:generateContent` | Generate content |
| POST | `/v1beta/models/{model}:streamGenerateContent` | Stream generate content |

## Basic Request

```
curl "https://api.silentapi.com/v1beta/models/gemini-4-neon:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -d '{
    "contents": [{
      "parts": [{ "text": "What is quantum entanglement?" }]
    }]
  }'
```

Response:

```
{
  "candidates": [{
    "content": {
      "role": "model",
      "parts": [{ "text": "Quantum entanglement is a phenomenon..." }]
    },
    "finishReason": "STOP"
  }],
  "usageMetadata": {
    "promptTokenCount": 6,
    "candidatesTokenCount": 142,
    "totalTokenCount": 148
  },
  "silentapi": {
    "cost": 0.000038,
    "fallback": null
  }
}
```

## Using the Google GenAI SDK

### Python

```
from google import genai

client = genai.Client(
    api_key="YOUR_API_KEY",
    http_options={"base_url": "https://api.silentapi.com"}
)

response = client.models.generate_content(
    model="gemini-4-neon",
    contents="What is quantum entanglement?"
)
print(response.text)
```

### JavaScript

```
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({
    apiKey: "YOUR_API_KEY",
    httpOptions: { baseUrl: "https://api.silentapi.com" }
});

const response = await ai.models.generateContent({
    model: "gemini-4-neon",
    contents: "What is quantum entanglement?"
});
const responseText = response.text;
```

## Supported Parameters

Gemini 4 Carbon, Gemini 4 Neon, and Gemini 4 Hydrogen have a 1M token context, and older Gemini model names run the matching Gemini 4 model. SilentAPI does not automatically join continuation requests.

| Parameter | Type | Description |
| --- | --- | --- |
| contents | array | Conversation turns with parts |
| systemInstruction | object or string | System instruction. An object contains text parts. |
| generationConfig | object | Supports temperature, topP, maxOutputTokens, stopSequences, and response schemas |
| generationConfig.thinkingConfig.thinkingLevel | string | Reasoning level: `minimal`, `low`, `medium`, or `high`. A model without the level gets the closest level, for example `minimal` becomes `low` on `gemini-3.8-flash`. See [Reasoning](https://silentapi.com/docs/openai#reasoning). |
| generationConfig.thinkingConfig.thinkingBudget | integer | Token budget for reasoning. See the table below. |
| generationConfig.thinkingConfig.includeThoughts | boolean | `false` leaves out the thinking text. When absent, thinking text is returned when the model gives it. |
| tools | array | Function declarations or Google Search grounding |
| toolConfig | object | Function calling configuration |
| safetySettings | array | Safety filter configuration |

## Reasoning

SilentAPI changes `thinkingBudget` to a reasoning level:

| thinkingBudget | Reasoning level |
| --- | --- |
| Less than 0 | `medium` |
| 0 | `none`. Reasoning is off on models that can turn it off. Other models use their lowest level. |
| 1 to 2,048 | `low` |
| 2,049 to 8,192 | `medium` |
| 8,193 to 32,768 | `high` |
| 32,769 to 65,536 | `xhigh` |
| More than 65,536 | `max` |

When both fields exist, `thinkingLevel` is used. An unknown `thinkingLevel` is ignored, and `thinkingBudget` is used instead. Each model supports its own set of levels, and SilentAPI changes an unsupported level to the closest supported one. See [Reasoning](https://silentapi.com/docs/openai#reasoning) for the rules.

### Parameter Handling

| Request | Handling |
| --- | --- |
| `thinkingLevel` on a model with other levels | The closest level the model supports |
| `thinkingBudget` on any model | Changed to a level with the table above, then to the closest level the model supports |
| `temperature` above 2, `topP` above 1 | Limited to 2 and 1. See [Parameter Handling](https://silentapi.com/docs/openai#parameter-handling). |

## Grounding

Use `tools` to request Google Search grounding. Support depends on the selected model, and grounding can add a request charge. Maps grounding is not supported and returns an error before the request is sent. Read current prices on the [Services page](https://silentapi.com/services) and [Calculator](https://silentapi.com/calculator).

```
curl "https://api.silentapi.com/v1beta/models/gemini-4-neon:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -d '{
    "contents": [{ "parts": [{ "text": "What is the latest news on Mars exploration?" }] }],
    "tools": [{"googleSearch": {}}]
  }'
```

## Cross-Style Usage

Use any supported text or multimodal model with `generateContent`. The response uses the Gemini format.

## Streaming

Use `:streamGenerateContent` to receive server-sent events (SSE), where each chunk contains candidate parts. See [Streaming](https://silentapi.com/docs/streaming) for details.

Source: https://silentapi.com/docs/gemini
