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

# Use Gemini API via Runcrate

> Access Google's Gemini 2.5 Pro and Flash through the Runcrate API — long-context, vision, and structured output with a single API key.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

Access Google's Gemini models through the Runcrate API. Same models, OpenAI-compatible format, no Google Cloud project required.

## Available Gemini models

| Model                | Context   | Strengths                                  |
| -------------------- | --------- | ------------------------------------------ |
| **Gemini 2.5 Pro**   | 1M tokens | Strongest reasoning, long-context analysis |
| **Gemini 2.5 Flash** | 1M tokens | Fast inference, cost-effective             |

***

## Basic usage

<CodeGroup>
  ```python Python theme={"theme":"github-dark"}
  from runcrate import Runcrate

  client = Runcrate(api_key="rc_live_YOUR_API_KEY")

  response = client.models.chat_completion(
      model="google/gemini-2.5-pro",
      messages=[
          {"role": "user", "content": "Explain how self-attention works in transformers. Include the math."},
      ],
      max_tokens=1024,
  )

  print(response.choices[0].message.content)
  ```

  ```typescript Vercel AI SDK theme={"theme":"github-dark"}
  import { runcrate } from '@runcrate/ai';
  import { generateText } from 'ai';

  const { text } = await generateText({
    model: runcrate('google/gemini-2.5-pro'),
    prompt: 'Explain how self-attention works in transformers. Include the math.',
  });
  ```

  ```bash curl theme={"theme":"github-dark"}
  curl https://api.runcrate.ai/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer rc_live_YOUR_API_KEY" \
    -d '{
      "model": "google/gemini-2.5-pro",
      "messages": [{"role": "user", "content": "Explain self-attention in transformers."}]
    }'
  ```
</CodeGroup>

***

## Long-context analysis (1M tokens)

Gemini's 1M token context handles entire codebases or books in a single request:

```python theme={"theme":"github-dark"}
from runcrate import Runcrate

client = Runcrate(api_key="rc_live_YOUR_API_KEY")

codebase = open("full-codebase.txt").read()

response = client.models.chat_completion(
    model="google/gemini-2.5-pro",
    messages=[
        {"role": "system", "content": "You are a senior engineer performing a code review."},
        {"role": "user", "content": f"Review this codebase for security and performance issues:\n\n{codebase}"},
    ],
    max_tokens=4096,
)

print(response.choices[0].message.content)
```

***

## Vision — image analysis

```python theme={"theme":"github-dark"}
from runcrate import Runcrate
import base64

client = Runcrate(api_key="rc_live_YOUR_API_KEY")

with open("diagram.png", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode()

response = client.models.chat_completion(
    model="google/gemini-2.5-flash",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this architecture diagram. List all services and connections."},
            {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{image_b64}"}},
        ],
    }],
)

print(response.choices[0].message.content)
```

***

## Runcrate vs. direct Google API

|                  | Direct Google API                      | Runcrate              |
| ---------------- | -------------------------------------- | --------------------- |
| **Auth**         | Google Cloud project + service account | Single API key        |
| **Format**       | Google-specific SDK                    | OpenAI-compatible     |
| **Other models** | Gemini only                            | 140+ models, same key |

***

## Pro vs. Flash

| Scenario                | Model            | Why                     |
| ----------------------- | ---------------- | ----------------------- |
| Complex reasoning       | Gemini 2.5 Pro   | Stronger reasoning      |
| Bulk processing         | Gemini 2.5 Flash | Faster, cheaper         |
| Real-time chat          | Gemini 2.5 Flash | Lower latency           |
| Vision / image analysis | Either           | Both support multimodal |

***

## Tips

* **1M context is real** — you can feed entire repositories or book-length texts.
* **Gemini 2.5 Flash** is the cost-effective choice for high-volume tasks.
* **Same API format**: just change the model string from DeepSeek or Llama.

## Next steps

* [Chat completions reference](/models/chat-completions)
* [AI Summarization](/examples/ai-summarization) — Gemini Flash for long-document summarization
* [Model catalog](/models/model-catalog)
