> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Gemini 3.6 Flash API

> Call Gemini 3.6 Flash with the exact model ID and read the native response.

Use `model: "gemini-3.6-flash"` to call Gemini 3.6 Flash. The examples below send a synchronous request using OpenAI Chat Completions.

These are integration examples, not recorded model outputs. Keep the key in your server environment as `BEATAPI_API_KEY`; replace `<BEATAPI_API_KEY>` in the cURL example with your own key. Do not put the key in browser code.

## Send a request

`POST https://api.beatapi.io/v1/chat/completions`

Install `openai` in your server project.

```typescript
import OpenAI from "openai";

const apiKey = process.env.BEATAPI_API_KEY;
if (!apiKey) throw new Error("Set BEATAPI_API_KEY in your server environment.");

const client = new OpenAI({
  apiKey,
  baseURL: "https://api.beatapi.io/v1",
});

const completion = await client.chat.completions.create({
  model: "gemini-3.6-flash",
  max_tokens: 2048,
  messages: [{ role: "user", content: "Classify the following support ticket using exactly one label: account_access, billing, or product_defect. Return the label and a brief reason. Ticket: I reset my password, but the new password still does not let me sign in." }],
});

const choice = completion.choices[0];
if (!choice || choice.finish_reason !== "stop") {
  throw new Error(`Handle the finish reason before accepting the result: ${choice?.finish_reason}`);
}
const text = choice.message.content;
if (typeof text !== "string" || !text.trim()) {
  throw new Error("The response contains no text answer.");
}
console.log(text);
console.log({ id: completion.id, model: completion.model, usage: completion.usage });
```

`max_tokens: 2048` is the budget for thinking and the visible answer in this request, not a maximum model limit. Inspect actual completion usage and handle a truncated answer instead of treating an HTTP 200 as acceptance.

### cURL

```bash
curl --request POST \
  --url https://api.beatapi.io/v1/chat/completions \
  --header 'Authorization: Bearer <BEATAPI_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gemini-3.6-flash",
  "max_tokens": 2048,
  "messages": [
    {
      "role": "user",
      "content": "Classify the following support ticket using exactly one label: account_access, billing, or product_defect. Return the label and a brief reason. Ticket: I reset my password, but the new password still does not let me sign in."
    }
  ]
}'
```

## Read and validate the result

Read the answer from `choices[0].message.content`, then inspect the actual `finish_reason` and `usage`. The example accepts `stop`; a truncated answer or a tool request needs separate application handling. Validate the returned label against your allowed labels before using it to route a ticket.

An HTTP 200 alone does not prove that the answer satisfies your task. Validate the content in your application. These text requests return directly; do not poll `/v1/tasks` for them.

Check `GET /v1/models` for the model IDs available to your account. This minimal example does not claim support for additional reasoning, sampling, cache-control or hosted-tool settings.