Source: https://ailoot.ai/docs/tr/connect/google-genai/
Canonical: https://ailoot.ai/docs/tr/connect/google-genai/
Language: tr

[Bağlantı](https://ailoot.ai/docs/tr/) 

# Google GenAI SDK

[Markdown formatı](https://ailoot.ai/docs/tr/connect/google-genai/index.md)

– Native Gemini formatı: Python ve JavaScript için Google GenAI SDK; doğrudan REST istekleri.

## [](https://ailoot.ai/docs/tr/connect/google-genai/#install)Kurulum.

```bash
pip install google-genai
```

```bash
npm install @google/genai
```

## [](https://ailoot.ai/docs/tr/connect/google-genai/#client)Bağlantı

– URL adresi… `https://api.ailoot.ai` İle birlikte… `/v1beta`– SDK tarafından oluşturulan yol… `/v1beta/models/<model>:generateContent` – Python’da URL adresini belirleyin; JavaScript’te ise… `HttpOptions(base_url=…)`JavaScript’te, yoluyla… `httpOptions.baseUrl`. SDK, `x-goog-api-key`.

```python
from google import genai
from google.genai import types
import os

client = genai.Client(
    api_key=os.environ["AILOOT_API_KEY"],
    http_options=types.HttpOptions(base_url="https://api.ailoot.ai"),  # without /v1beta
)

resp = client.models.generate_content(
    model="gemini-3.8-flash",
    contents="Come up with three names for a coffee shop.",
)
print(resp.text)
```

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

const ai = new GoogleGenAI({
  apiKey: process.env.AILOOT_API_KEY,
  httpOptions: { baseUrl: "https://api.ailoot.ai" }, // without /v1beta
});

const resp = await ai.models.generateContent({
  model: "gemini-3.8-flash",
  contents: "Come up with three names for a coffee shop.",
});
console.log(resp.text);
```

```bash
curl "https://api.ailoot.ai/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "x-goog-api-key: $AILOOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "Come up with three names for a coffee shop."}]}
    ]
  }' 
```

## [](https://ailoot.ai/docs/tr/connect/google-genai/#body)Desteklenen girdiler,

- Üst düzey alanlar; `contents`, `systemInstruction`, `generationConfig`, `safetySettings`, `tools` ve `toolConfig`.
- `generationConfig` – Kabul edilir `temperature`, `topP`, `topK`, `maxOutputTokens`, `thinkingConfig`, `responseMimeType` (`text/plain` veya `application/json`), `responseSchema` veya `responseJsonSchema` – Bir JSON nesnesi `stopSequences` – Bir dizi string `candidateCount: 1`– Bir tam sayı `seed`– Sayısal değerler `presencePenalty` ve `frequencyPenalty`– Desteklenen aralıklar ve yetenekler, modela bağlıdır. Bir JSON yanıtı için, desteklenen bir şema formatını seçin ve `application/json`’u kullanın. Metin modelleri için… `responseModalities` – Sadece `["TEXT"]`.
- `safetySettings` – Objelerden oluşan bir dizi; `category`, `threshold` ve isteğe bağlı; `method`Değerleri, modelle ilgili dokümantasyona göre seçin.
- İlgili girdiyi destekleyen Gemini modelleri için… `parts[].inlineData` , `mimeType` ve boş olmayan Base64 formatında veriler içerir. Bir PDF dosyasının gerçek bir PDF dosyası olması gerekir. `fileData` ’de, kamuya açık URL’ler bulunur. `https` URL’yi şu alanda kullanın: `fileUri` Ayrıca, dosyanın MIME türü de önemlidir. YouTube için bu MIME türü gereksiz olabilir. `http`Özel URL’ler. `gs://` Google Files’teki API nesneleri desteklenmiyor. Ayrıca, Google Files’ten API yoluyla yapılan yüklemeler de desteklenmiyor. Video için ise, şunu yapabilirsiniz: `videoMetadata`: `startOffset`/`endOffset` Saniyeler cinsinden ifade edilen dizeler… Örneğin, `1.5s`ve `fps` değerleri 0’den büyük ve 24’e eşit olmalıdır). Model ve format için istek gövdesinin boyutu, desteklenen girdiler ve yanıt sınırları kontrol edilir.
- İstemci tarafında `functionDeclarations` Uygulamanız tarafından yürütülür. Metin modelleri ayrıca şunları da kabul eder: `{"googleSearch": {}}` ve `{"urlContext": {}}`: Bireysel olarak veya bir dizi içinde birlikte `tools`Ne Google Arama ne de URL bağlamı birleştirilemez. `functionDeclarations` Aynı istekte. Yalnızca görüntü çıktısı için kullanılabilir olan şeyler, client taraf fonksiyonlardır. Diğer yerleşik araçlar ve açıkça belirtilen önbellekler desteklenmemektedir. Arama/URL bağlamı, tam giriş sınırlarına göre bir rezerv gerektirebilir; gerçek olarak bildirilen belirteçler… `toolUsePromptTokenCount` , girdi tokenları olarak sayılır.
- Eğer model, bir alanı, ekleri veya araç kombinasyonlarını desteklemiyorsa, talepler reddedilir ve herhangi bir ücret alınmaz. Böyle durumlarda sadece HTTP alırsınız. `400` türündeki olaylar gönderilir. Bu olayda `status` `INVALID_ARGUMENT` ve sınıf bilgileri… `invalid_request` ( `ErrorInfo.reason` — `INVALID_REQUEST`’da). Geçersiz JSON, yol parametreleri hataları ve diğer doğrulama hataları da `400`sonucunu verir; hata mesajını ve talepteki bilgileri okuyun. Yetenekler modelden modelye değişiklik gösterir; formatları ve girdi bilgilerini katalogda kontrol edin.

| Giriş | Desteklenen MIME türleri |
| --- | --- |
| İçinde bulunduğu metin içeren resimler | image/png, image/jpeg, image/webp |
| Belgeler | application/pdf; text/plain, text/html, text/css, text/csv, text/xml, text/rtf, text/markdown, text/javascript, application/x-javascript, text/x-python, application/x-python |
| Ses | audio/wav, audio/mp3, audio/mpeg, audio/aiff, audio/aac, audio/ogg, audio/flac |
| Video | video/mp4, video/mpeg, video/mov, video/quicktime, video/avi, video/x-flv, video/mpg, video/webm, video/wmv, video/3gpp |

```python
import json, os, urllib.request

def generate(model, payload):
    req = urllib.request.Request(
        "https://api.ailoot.ai/v1beta/models/" + model + ":generateContent",
        data=json.dumps(payload).encode(),
        headers={"x-goog-api-key": os.environ["AILOOT_API_KEY"],
                 "Content-Type": "application/json"},
    )
    # One send. After a timeout, check the Request ID in your usage history before retrying.
    with urllib.request.urlopen(req, timeout=300) as response:
        print("Request ID:", response.headers.get("X-Request-ID"))
        return json.load(response)

import base64, pathlib, sys

# Supply a real local PDF, audio or video file and its supported MIME type.
path, mime = pathlib.Path(sys.argv[1]), sys.argv[2]
payload = {"contents": [{"role": "user", "parts": [
    {"text": "Briefly describe the contents of the file."},
    {"inlineData": {"mimeType": mime,
                    "data": base64.b64encode(path.read_bytes()).decode()}},
]}]}
print(generate("gemini-3.8-flash", payload))
# Alternative attachment: {"fileData": {"mimeType": mime, "fileUri": public_https_url}}
# For a real YouTube URL: {"fileData": {"fileUri": youtube_url}}
```

## [](https://ailoot.ai/docs/tr/connect/google-genai/#function-loop)Tam işlev çağrısı iş akışı;

Deklarasyonu gönderin, functionCall’ı alın, fonksiyonunuzu çalıştırın, functionResponse’ı döndürün ve bir sonraki yanıtı talep edin. Modelin tüm içeriğini koruyun; thoughtSignature de dahil. Bu imzayı kendiniz oluşturmayın.

```python
import json, os, urllib.request

def generate(model, payload):
    req = urllib.request.Request(
        "https://api.ailoot.ai/v1beta/models/" + model + ":generateContent",
        data=json.dumps(payload).encode(),
        headers={"x-goog-api-key": os.environ["AILOOT_API_KEY"],
                 "Content-Type": "application/json"},
    )
    # One send. After a timeout, check the Request ID in your usage history before retrying.
    with urllib.request.urlopen(req, timeout=300) as response:
        print("Request ID:", response.headers.get("X-Request-ID"))
        return json.load(response)

tools = [{"functionDeclarations": [{
    "name": "multiply", "description": "Multiply two numbers",
    "parameters": {"type": "object", "properties": {
        "a": {"type": "number"}, "b": {"type": "number"}},
        "required": ["a", "b"]},
}]}]
contents = [{"role": "user", "parts": [{"text": "Multiply 7 by 8 using the function"}]}]
for turn in range(4):  # Bound the tool loop; do not resend a request whose result is unclear.
    reply = generate("gemini-3.8-flash", {"contents": contents, "tools": tools})
    content = reply["candidates"][0]["content"]
    contents.append(content)  # Keep ALL original parts and thoughtSignature unchanged.
    results = []
    for part in content.get("parts", []):
        call = part.get("functionCall")
        if not call:
            continue
        if call["name"] != "multiply":
            raise ValueError("Unexpected function")
        args = call["args"]
        result = {"name": call["name"], "response": {"value": args["a"] * args["b"]}}
        if "id" in call:
            result["id"] = call["id"]
        results.append({"functionResponse": result})
    if not results:
        print(content)
        break
    contents.append({"role": "user", "parts": results})
else:
    raise RuntimeError("Tool loop limit reached")
```

## [](https://ailoot.ai/docs/tr/connect/google-genai/#stream)Akışlı yanıtlar

```python
for chunk in client.models.generate_content_stream(
    model="gemini-3.8-flash",
    contents="Describe a sunset over the sea",
):
    print(chunk.text, end="", flush=True)
```

```bash
curl -N "https://api.ailoot.ai/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: $AILOOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents": [{"role": "user", "parts": [{"text": "Describe a sunset over the sea"}]}]}' 
```

Ailoot, maliyetlerini hesapladıktan sonra Gemini yanıtlarını sunar. Metin, model çalıştırıldığında tam olarak gelir; kelime kelime değil. Gemini yanıtlarında herhangi bir kontrol satırı bulunmaz; bu nedenle uzun yanıtlar için müşteri zaman aşımını artırmanız gerekir.

## [](https://ailoot.ai/docs/tr/connect/google-genai/#models)Kullanılabilir modeller…

`Gemini` · [Anahtara sahip olduğunuz modellerin listesi; desteklenen formatlar ve fiyatlarla birlikte…](https://ailoot.ai/docs/tr/api/models/) (`GET /v1/models`). `gemini-3.8-flash`, `gemini-3.1-pro`, `gemini-pro-agent`, `gemini-3.8-flash-tiered`, `gemini-3.8-flash-medium`, `gemini-3.8-flash-low`, `gemini-3.8-flash-high`, `gemini-3.7-flash`, `gemini-3.7-flash-tiered`, `gemini-3.7-flash-medium`, `gemini-3.7-flash-low`, `gemini-3.7-flash-high`, `gemini-3.6-flash`, `gemini-3.6-flash-tiered`, `gemini-3.6-flash-medium`, `gemini-3.6-flash-low`, `gemini-3.6-flash-high`, `gemini-3.5-flash-lite`, `gemini-3.1-pro-preview`, `gemini-3.1-pro-low`, `gemini-3.1-pro-high`, `gemini-3.1-flash-lite`, `gemini-3-flash`, `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-2.5-flash-thinking`, `gemini-2.5-flash-lite` …

Gemini modelleri aynı zamanda Anthropic mesaj formatında da mevcuttur. Bu, sadece bu formatı destekleyen müşteriler için faydalıdır. [Anthropic SDK](https://ailoot.ai/docs/tr/connect/anthropic-sdk/).

Hâlâ sorularınız mı var? Lütfen talebinizin ID’sini ve açıklamasını gönderin; size yardım edeceğiz.[Destek hattıyla iletişime geçin.](mailto:support@ailoot.ai)

## Ailoot · Şirket ve projeler…





Ailoot, güçlü iş deneyimine, geniş müşteri tabanına, stabil hizmete ve sürekli KPI kontrolüne sahiptir.





Şirket ve projeler portföyü: Milyonlarca müşteri; aylık satışlar milyarlarca dolar.





Ailoot, bu iş deneyimini API’e sunar. Böylece müşteri ürünlerinde, acentelerde, uygulamalarda ve otomasyonlarda AI özellikleri kullanılabilir.
