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

# Embeddings API

> Semantik arama, kümeleme, öneriler ve retrieval iş akışları için vektörler oluşturmak üzere CometAPI embeddings rotalarını kullanın.

Uygulamanız semantik arama, kümeleme, öneriler veya retrieval için vektörlere ihtiyaç duyduğunda CometAPI embeddings kullanın. Metni `/v1/embeddings` adresine gönderin, döndürülen vektörü saklayın ve vektör veritabanınızla arayın.

## Bir embedding oluşturun

[Models sayfasından](/tr/overview/models) veya [model directory](https://www.cometapi.com/models/) içinden embedding destekleyen bir model ID kullanın. Aşağıdaki örnekler, OpenAI uyumlu Embeddings API'yi çağırır.

<Note>
  Bu örneklerde `your-embedding-model-id` yer tutucusu kullanılır. İsteği çalıştırmadan önce bunu [Models sayfasından](/tr/overview/models) veya [model directory](https://www.cometapi.com/models/) içindeki kullanılabilir bir embedding model ID ile değiştirin.
</Note>

<Tip>
  Playground ve endpoint şemasını kullanmak için [Create embeddings](/api/text/embeddings) sayfasını açın.
</Tip>

<CodeGroup>
  ```python Python theme={null}
  import os
  import requests

  response = requests.post(
      "https://api.cometapi.com/v1/embeddings",
      headers={
          "Authorization": "Bearer " + os.environ["COMETAPI_KEY"],
          "Content-Type": "application/json",
      },
      json={
          "model": "your-embedding-model-id",
          "input": "CometAPI lets developers use many model providers.",
      },
      timeout=30,
  )

  response.raise_for_status()
  result = response.json()
  print(len(result["data"][0]["embedding"]))
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.cometapi.com/v1/embeddings", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "your-embedding-model-id",
      input: "CometAPI lets developers use many model providers.",
    }),
  });

  if (!response.ok) {
    throw new Error(await response.text());
  }

  const result = await response.json();
  console.log(result.data[0].embedding.length);
  ```

  ```bash cURL theme={null}
  curl https://api.cometapi.com/v1/embeddings \
    -H "Authorization: Bearer $COMETAPI_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "your-embedding-model-id",
      "input": "CometAPI lets developers use many model providers."
    }'
  ```
</CodeGroup>

## Yanıt örneği

Başarılı bir yanıt şu şekilde görünebilir. Yanıt, her input öğesi için bir vektör içerir; aşağıdaki vektör okunabilirlik için kısaltılmıştır:

```json theme={null}
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        -0.0021,
        -0.0491,
        0.0209
      ]
    }
  ],
  "model": "your-embedding-model-id",
  "usage": {
    "prompt_tokens": 10,
    "total_tokens": 10
  }
}
```

## Toplu input

Tek bir istekte birden fazla vektör istediğinizde bir string dizisi gönderin:

```bash cURL theme={null}
curl https://api.cometapi.com/v1/embeddings \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-embedding-model-id",
    "input": [
      "Create an API key",
      "Change the base URL",
      "Retry after a rate limit"
    ]
  }'
```

## Örnek model kayıtları

<Info>
  Bu örnek model kataloğu yanıtı, `/api/models` zarfını ve OpenAI uyumlu bir Embeddings model kaydı şeklini gösterir. Bazı embedding kayıtları boş bir `model_type` kullanır; yalnızca bu alana güvenmek yerine bir embedding modelini ID ve endpoint desteğine göre seçin.
</Info>

```bash cURL theme={null}
curl https://api.cometapi.com/api/models
```

```json theme={null}
{
  "success": true,
  "page": 1,
  "page_size": 20,
  "total": 302,
  "data": [
    {
      "created": 1757904564,
      "id": "your-embedding-model-id",
      "code": "your-embedding-model-id",
      "provider": "ExampleProvider",
      "provider_code": "example",
      "name": "Example embedding model",
      "model_type": "embedding",
      "features": [
        "text-embedding"
      ],
      "endpoints": [
        "openai"
      ],
      "pricing": {
        "currency": "USD / M Tokens",
        "input": 0.1,
        "output": null,
        "per_request": null,
        "per_second": null
      }
    }
  ]
}
```

## Yaygın hatalar

<AccordionGroup>
  <Accordion title="Input too long">
    Embedding işleminden önce uzun belgeleri parçalara ayırın.
  </Accordion>

  <Accordion title="Wrong model type">
    Model dizininden embedding destekleyen bir model seçin.
  </Accordion>

  <Accordion title="Vector dimensions mismatch">
    Tek bir vektör indeksi için aynı model ve boyutları kullanın.
  </Accordion>

  <Accordion title="Missing API key">
    `Authorization: Bearer $COMETAPI_KEY` gönderin.
  </Accordion>
</AccordionGroup>

## Hata kodları ve yeniden deneme stratejisi

<AccordionGroup>
  <Accordion title="400">
    Girdi, model ID veya dimensions ayarı düzeltilene kadar yeniden denemeyin.
  </Accordion>

  <Accordion title="401">
    API anahtarı mevcut ve geçerli olana kadar yeniden denemeyin.
  </Accordion>

  <Accordion title="404">
    Yeniden denemeden önce base URL, path ve model ID değerlerini kontrol edin.
  </Accordion>

  <Accordion title="429">
    Üstel backoff ile yeniden deneyin ve batch boyutunu veya eşzamanlılığı azaltın.
  </Accordion>

  <Accordion title="500 or 503">
    Geçici provider veya hizmet hataları için backoff ile yeniden deneyin.
  </Accordion>
</AccordionGroup>

<Tip>
  Uygulama kalıpları için [Hata kodları ve yeniden deneme stratejisi](/tr/guides/error-codes-and-retry-strategy) ve [Oran limitleri ve eşzamanlılık](/tr/guides/rate-limits-and-concurrency) bölümlerine bakın.
</Tip>

## Fiyatlandırma ve model dizini

<CardGroup cols={3}>
  <Card title="Models page" icon="list" href="/overview/models">
    Belgelerde CometAPI'nin model ID değerlerini nasıl sunduğunu öğrenin.
  </Card>

  <Card title="Model directory" icon="puzzle-piece" href="https://www.cometapi.com/models/">
    Model kullanılabilirliğine ve yeteneklerine göz atın.
  </Card>

  <Card title="Pricing" icon="tag" href="https://www.cometapi.com/pricing/">
    Bir modeli çağırmadan önce fiyatlandırmayı kontrol edin.
  </Card>
</CardGroup>
