# Google API

Use Google's native request and response format with a supported Google model.

## Endpoint

`POST https://mia-ai-proxy.ambr.io/v1beta/models/{model}:generateContent`

Use the native model name from the model's [account model page](https://mia-ai-proxy.ambr.io/console) Quickstart, without the `google/` catalog prefix. Choose a model whose example uses `generateContent`; other Google models can use different operations.

## Request

Set `MIA_GOOGLE_MODEL` to that native model name.

```bash
curl "https://mia-ai-proxy.ambr.io/v1beta/models/$MIA_GOOGLE_MODEL:generateContent" \
  -H "x-goog-api-key: $MIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"Hello"}]}]}'
```

For SDK setup, see [Native APIs](https://mia-ai-proxy.ambr.io/docs/native-apis.md#google-gen-ai-sdk).

## Response

A text response includes:

```json
{
  "candidates": [{
    "content": {"role": "model", "parts": [{"text": "Hello!"}]},
    "finishReason": "STOP"
  }]
}
```

Read the parts in `candidates[].content.parts`. Parts can contain text, media, or function calls depending on the model. Preserve the complete content for subsequent turns, including thought signatures when returned.

## Check completion

Inspect each candidate's `finishReason`:

| Value | Meaning |
| --- | --- |
| `STOP` | Generation reached a natural stopping point or a stop sequence. |
| `MAX_TOKENS` | The output limit was reached; the answer may be incomplete. |
| `SAFETY` | The candidate was filtered for safety. |

If no candidate is returned, inspect `promptFeedback` and any error. For other values, use Google's [finish reason reference](https://ai.google.dev/api/generate-content#FinishReason).

## Streaming

Use `POST https://mia-ai-proxy.ambr.io/v1beta/models/{model}:streamGenerateContent?alt=sse` with the same body to receive server-sent events. Read each candidate's `finishReason`; a closed connection alone does not establish completion. See [Errors and retries](https://mia-ai-proxy.ambr.io/docs/errors.md) before repeating an interrupted request.

## Other operations

Google embeddings, image, video, audio, interactions, and live sessions have model-specific operations. Use the method and payload in the selected model's Quickstart rather than substituting `generateContent`.
