# Gemini 3.8 Flash

Use `gemini-3.8-flash` with the native Gemini format. The [model page](https://seedrouter.ai/models/gemini-3-8-flash#playground) includes the Playground and current prices; the [model comparison guide](https://seedrouter.ai/blog/gemini-3-8-flash-vs-gemini-3-1-pro) compares the documented settings with Gemini 3.1 Pro.

## Model ID

| Model ID           | Input limit      | Default effort |
| ------------------ | ---------------- | -------------- |
| `gemini-3.8-flash` | 1,048,576 tokens | `medium`       |

## Quick example

```bash
curl https://api.seedrouter.ai/v1beta/models/gemini-3.8-flash:generateContent \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"Explain a mutex in one sentence."}]}],"generationConfig":{"thinkingConfig":{"thinkingLevel":"low"},"maxOutputTokens":1024}}'
```

```python
import json
import os
from urllib.request import Request, urlopen

body = {
    "contents": [{"role": "user", "parts": [{"text": "Explain a mutex in one sentence."}]}],
    "generationConfig": {"thinkingConfig": {"thinkingLevel": "low"}, "maxOutputTokens": 1024},
}
request = Request(
    "https://api.seedrouter.ai/v1beta/models/gemini-3.8-flash:generateContent",
    data=json.dumps(body).encode(),
    headers={"Authorization": f"Bearer {os.environ['SEEDROUTER_API_KEY']}", "Content-Type": "application/json"},
    method="POST",
)
with urlopen(request) as response:
    print(json.load(response))
```

```javascript
const response = await fetch(
  "https://api.seedrouter.ai/v1beta/models/gemini-3.8-flash:generateContent",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.SEEDROUTER_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      contents: [{ role: "user", parts: [{ text: "Explain a mutex in one sentence." }] }],
      generationConfig: { thinkingConfig: { thinkingLevel: "low" }, maxOutputTokens: 1024 },
    }),
  },
);
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```

```go
package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
    "os"
)

func main() {
    body := []byte(`{"contents":[{"role":"user","parts":[{"text":"Explain a mutex in one sentence."}]}],"generationConfig":{"thinkingConfig":{"thinkingLevel":"low"},"maxOutputTokens":1024}}`)
    req, err := http.NewRequest("POST", "https://api.seedrouter.ai/v1beta/models/gemini-3.8-flash:generateContent", bytes.NewReader(body))
    if err != nil { panic(err) }
    req.Header.Set("Authorization", "Bearer " + os.Getenv("SEEDROUTER_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    resp, err := http.DefaultClient.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()
    out, err := io.ReadAll(resp.Body)
    if err != nil { panic(err) }
    fmt.Println(string(out))
}
```

The model belongs in the URL. `contents` is required. An answer includes native `candidates`, `finishReason` and `usageMetadata`; retain complete content parts, including `thoughtSignature`, for conversation history.

## Endpoints

| Operation          | Endpoint                                                             |
| ------------------ | -------------------------------------------------------------------- |
| JSON response      | `POST /v1beta/models/gemini-3.8-flash:generateContent`               |
| Server-sent events | `POST /v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse` |

The [OpenAPI specification](https://seedrouter.ai/docs/gemini-3-8-flash.openapi.json) includes every nested request and response schema. Optional fields use API defaults when omitted. SeedRouter forwards the submitted body without filtering unknown fields, removing unsupported fields or validating model parameter values. The Gemini API decides whether a request is accepted.

## Request parameters

The URL fixes the model to `gemini-3.8-flash`. The request contract contains 12 top-level fields. Fields are optional unless marked required; omission differs from JSON `null`. Nullable arbitrary JSON is preserved where the official schema permits it.

| Field               | Type      | Required | Default and constraints                                                        |
| ------------------- | --------- | -------- | ------------------------------------------------------------------------------ |
| `contents`          | object\[] | Yes      | Nonempty conversation; each content has nonempty `parts`                       |
| `systemInstruction` | object    | No       | Text-only parts; no automatic user identity is inserted                        |
| `generationConfig`  | object    | No       | Generation parameters in the next table                                        |
| `tools`             | object\[] | No       | Function declarations and built-in tool configurations                         |
| `toolConfig`        | object    | No       | Function selection and retrieval configuration                                 |
| `safetySettings`    | object\[] | No       | One setting per category; no duplicate categories                              |
| `cachedContent`     | string    | No       | Existing `cachedContents/{id}` resource; requires compatible access            |
| `serviceTier`       | string    | No       | `unspecified`, `standard`, `flex`, `priority`; ordinary processing is standard |
| `labels`            | object    | No       | String values; lowercase keys/values, maximum 63 Unicode codepoints each       |
| `model`             | string    | No       | Optional resource name; the URL determines the actual model                    |
| `store`             | boolean   | No       | Generic request storage preference; model-specific effect unverified           |
| `continuationToken` | string    | No       | Generic opaque token; continuation is not an established 3.8 Flash capability  |

### Generation parameters

| Field in `generationConfig`  | Type      | Default and constraints                                                                                                                                                                                                                                  |
| ---------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxOutputTokens`            | integer   | 1–65,536, including thinking; model default 65,536                                                                                                                                                                                                       |
| `thinkingConfig`             | object    | `thinkingLevel`: `low`, `medium`, `high` (default `medium`); uppercase spellings accepted. `includeThoughts`: boolean, default false. `thinkingBudget`: integer, mutually exclusive with `thinkingLevel`; no model-specific numeric range is established |
| `stopSequences`              | string\[] | Maximum five sequences                                                                                                                                                                                                                                   |
| `responseMimeType`           | string    | Default `text/plain`; legacy JSON schema output requires `application/json`                                                                                                                                                                              |
| `responseSchema`             | object    | Official schema dialect; mutually exclusive with `responseJsonSchema`                                                                                                                                                                                    |
| `responseJsonSchema`         | JSON      | JSON Schema; mutually exclusive with `responseSchema`                                                                                                                                                                                                    |
| `responseFormat`             | object    | Text format configuration; `text.mimeType` and optional `text.schema`. Schema requires JSON MIME type                                                                                                                                                    |
| `responseModalities`         | string\[] | Text only: `TEXT`; empty means text                                                                                                                                                                                                                      |
| `mediaResolution`            | enum      | `MEDIA_RESOLUTION_UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` with the `MEDIA_RESOLUTION_` prefix                                                                                                                                                              |
| `seed`                       | integer   | Signed 32-bit value; model-specific deterministic behavior unverified                                                                                                                                                                                    |
| `presencePenalty`            | number    | Generic field; model-specific effect/range unverified                                                                                                                                                                                                    |
| `frequencyPenalty`           | number    | Generic field; model-specific effect/range unverified                                                                                                                                                                                                    |
| `responseLogprobs`           | boolean   | Generic field; model-specific availability unverified                                                                                                                                                                                                    |
| `logprobs`                   | integer   | 0–20; requires `responseLogprobs: true`; model support unverified                                                                                                                                                                                        |
| `enableEnhancedCivicAnswers` | boolean   | Generic field; model support unverified                                                                                                                                                                                                                  |
| `enableAffectiveDialog`      | boolean   | Generic field; model support unverified                                                                                                                                                                                                                  |
| `audioTranscriptionConfig`   | object    | Generic field; model-specific options unverified                                                                                                                                                                                                         |
| `translationConfig`          | object    | Generic field; model-specific options unverified                                                                                                                                                                                                         |

The [OpenAPI document](https://seedrouter.ai/docs/gemini-3-8-flash.openapi.json) lists nested types, enums, required properties and documented bounds for every message. The schemas describe official parameters; they are not a SeedRouter request allowlist. Caller-supplied fields and values are preserved. A field accepted by the schema is not proof of support for every model or account. `minimal` thinking is not supported. Temperature, topP, topK and candidateCount are not official controls for this model. If submitted in native JSON, they still pass through unchanged for the Gemini API to handle. End the conversation with user content; the official API does not support final model-prefill turns. Function-response-only user turns remain valid.

## Structured output

```json
{
  "contents": [{"parts": [{"text": "Return a JSON object with ok set to true."}]}],
  "generationConfig": {
    "thinkingConfig": {"thinkingLevel": "low"},
    "maxOutputTokens": 1024,
    "responseMimeType": "application/json",
    "responseJsonSchema": {
      "type": "object",
      "properties": {"ok": {"type": "boolean"}},
      "required": ["ok"]
    }
  }
}
```

The legacy `responseSchema` and `responseJsonSchema` fields cannot be used together. Both require `responseMimeType: "application/json"`. The newer `responseFormat.text` schema must likewise specify JSON. Use REST enum spellings (`APPLICATION_JSON` and `TEXT_PLAIN`) in that message. Requests pass through unchanged; media MIME types and arbitrary function JSON are not rewritten.

## Functions and built-in tools

Use `tools[].functionDeclarations` with a name and either `parameters` or `parametersJsonSchema`, not both. Response schemas follow the same mutual-exclusion rule. Function selection lives in `toolConfig.functionCallingConfig`; `allowedFunctionNames` requires `ANY` or `VALIDATED` and declared names.

The model supports function calling. Your application executes returned functions and supplies their results in the next conversation turn. Preserve each original `thoughtSignature`, function call and function response. Do not round numeric identifiers when serializing opaque function arguments.

Google lists Search, Maps, code execution and URL context as model capabilities. File Search is supported in the model documentation. Existing cache and file-search resources require access under the credentials serving the request. Computer Use is listed as Preview. Native MCP configuration appears in the generic schema, but its availability for this model is not established. Google Maps requires text-only input and output; check the official API restrictions before combining Maps with media. The Playground does not execute your custom functions.

## Multimodal input and safety

A `contents[].parts[]` item contains exactly one payload: text, inline media, a file reference, a function call/response, or an execution part. It may also carry a signature or media metadata. Input supports text, images, audio, video and PDFs; output is text only.

For inline bytes, use `inlineData.mimeType` and base64 `data`. For file references, use `fileData.mimeType` and `fileUri`. A syntactically valid URL is not proof the model can retrieve it. Video metadata can specify start/end offsets and a positive `fps` no greater than 24. Global and per-part media resolutions are distinct settings. Agentic Video is supported through `videoMetadata.processingMode: "AGENTIC"`.

Use native JSON for inline media, or an accessible file reference for larger media. Exact file-format, duration and per-request media limits remain subject to the official media documentation and live verification.

Safety settings use the official native format. Omission leaves the Gemini API defaults in effect; explicitly supplied settings pass through unchanged.

## JSON responses and streaming

`generateContent` returns native JSON. `streamGenerateContent?alt=sse` emits native JSON in SSE `data:` events. Important fields include `candidates[].content.parts`, `finishReason`, `safetyRatings`, `groundingMetadata`, `promptFeedback`, `modelVersion`, `responseId` and `usageMetadata`.

Retain complete native content in conversation history. Thinking summaries are not the same as thought signatures. A disconnect does not prove generation failed or completed; inspect the partial result and account record before sending another request. Stream usage is cumulative, so use the latest counters instead of summing every chunk.

Longer-output continuation has not been established for Gemini 3.8 Flash. Do not build a continuation loop merely because the generic response schema includes a token field.

## Usage and pricing

`promptTokenCount` includes cached input. `cachedContentTokenCount` is charged at the cached-input rate, rather than charged again as uncached input. Billable output includes `candidatesTokenCount` plus `thoughtsTokenCount`. Reported tool-use prompt tokens also contribute to input.

There is no 200,000-token long-context price step for this model. Available account groups use the same model price expression and their own current multiplier. See the [live pricing table](https://seedrouter.ai/models/gemini-3-8-flash#pricing).

Flex and Priority are separate processing tiers. Flex uses half of Standard input, output and cached-input rates; Priority uses 1.8 times those rates. Published introductory Google rates end December 31, 2026; always check the current SeedRouter table rather than assuming a future rate. A reported Standard result must not incur a Priority surcharge. If a requested Priority response does not establish its actual tier, this integration uses Standard token rates. Tool charges and explicit cache storage are separate from generation-token pricing; no shared free tool allowance is promised. Failed requests are not charged.

## Multiple account groups

The model uses `googlellm` and `googlellm-vertext`, retaining their existing account permissions and pricing. The spelling of each group name is exact. Select an available group in the Playground, or use the optional API header:

```http
X-SeedRouter-Group: googlellm
```

Use `googlellm-vertext` to select the second group. The chosen group determines the price and available capacity; an explicit selection does not silently switch to another group. Omit the header or use `auto` to keep the API key's default behavior.

Check your API key's available groups without generating a response:

```bash
curl "https://api.seedrouter.ai/api/seedrouter/llm/groups?model=gemini-3.8-flash"   -H "Authorization: Bearer YOUR_SEEDROUTER_KEY"
```

## Verification status

The controls and documentation follow the official native format. Parameter validation belongs to the Gemini API. Offline transport and billing checks do not establish production availability. Live generation, both account groups, media understanding, cached resources, built-in tools and processing tiers still require paid end-to-end verification. No measured quality or latency comparison with Gemini 3.1 Pro is claimed.

## References

* [Google model specification](https://ai.google.dev/gemini-api/docs/models/gemini-3.8-flash)
* [Gemini 3.8 changes](https://ai.google.dev/gemini-api/docs/generate-content/whats-new-gemini-3.8)
* [GenerateContent REST reference](https://ai.google.dev/api/generate-content)
* [Structured output](https://ai.google.dev/gemini-api/docs/generate-content/structured-output)
* [Thinking](https://ai.google.dev/gemini-api/docs/generate-content/thinking)
* [Pricing](https://ai.google.dev/gemini-api/docs/pricing)
