> ## Documentation Index
> Fetch the complete documentation index at: https://portkey-docs-feat-rerank-documentation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Voyage AI

> Use Voyage AI's embeddings and reranking models through Portkey.

## Quick Start

Get started with Voyage AI in under 2 minutes:

<CodeGroup>
  ```python Python icon="python" theme={"system"}
  from portkey_ai import Portkey

  # 1. Install: pip install portkey-ai
  # 2. Add @voyage provider in model catalog
  # 3. Use it:

  portkey = Portkey(api_key="PORTKEY_API_KEY")

  embedding = portkey.embeddings.create(
      model="@voyage/voyage-3",
      input="Name the tallest buildings in Hawaii"
  )

  print(embedding.data[0].embedding)
  ```

  ```js Javascript icon="square-js" theme={"system"}
  import Portkey from 'portkey-ai'

  // 1. Install: npm install portkey-ai
  // 2. Add @voyage provider in model catalog
  // 3. Use it:

  const portkey = new Portkey({
      apiKey: "PORTKEY_API_KEY"
  })

  const embedding = await portkey.embeddings.create({
      model: "@voyage/voyage-3",
      input: "Name the tallest buildings in Hawaii"
  })

  console.log(embedding.data[0].embedding)
  ```

  ```python OpenAI Py icon="python" theme={"system"}
  from openai import OpenAI
  from portkey_ai import PORTKEY_GATEWAY_URL

  # 1. Install: pip install openai portkey-ai
  # 2. Add @voyage provider in model catalog
  # 3. Use it:

  client = OpenAI(
      api_key="PORTKEY_API_KEY",  # Portkey API key
      base_url=PORTKEY_GATEWAY_URL
  )

  embedding = client.embeddings.create(
      model="@voyage/voyage-3",
      input="Name the tallest buildings in Hawaii"
  )

  print(embedding.data[0].embedding)
  ```

  ```js OpenAI JS icon="square-js" theme={"system"}
  import OpenAI from "openai"
  import { PORTKEY_GATEWAY_URL } from "portkey-ai"

  // 1. Install: npm install openai portkey-ai
  // 2. Add @voyage provider in model catalog
  // 3. Use it:

  const client = new OpenAI({
      apiKey: "PORTKEY_API_KEY",  // Portkey API key
      baseURL: PORTKEY_GATEWAY_URL
  })

  const embedding = await client.embeddings.create({
      model: "@voyage/voyage-3",
      input: "Name the tallest buildings in Hawaii"
  })

  console.log(embedding.data[0].embedding)
  ```

  ```bash cURL icon="square-terminal" theme={"system"}
  # 1. Add @voyage provider in model catalog
  # 2. Use it:

  curl https://api.portkey.ai/v1/embeddings \
    -H "Content-Type: application/json" \
    -H "x-portkey-api-key: $PORTKEY_API_KEY" \
    -d '{
      "model": "@voyage/voyage-3",
      "input": "Name the tallest buildings in Hawaii"
    }'
  ```
</CodeGroup>

<Note>
  **Tip:** You can also set `provider="@voyage"` in `Portkey()` and use just `model="voyage-3"` in the request.
</Note>

## Add Provider in Model Catalog

Before making requests, add Voyage AI to your Model Catalog:

1. Go to [**Model Catalog → Add Provider**](https://app.portkey.ai/model-catalog/providers)
2. Select **Voyage AI**
3. Enter your [Voyage API key](https://dash.voyageai.com/)
4. Name your provider (e.g., `voyage`)

<Card title="Complete Setup Guide" icon="book" href="/product/model-catalog">
  See all setup options and detailed configuration instructions
</Card>

***

## Voyage AI Capabilities

### Embeddings

Generate high-quality embeddings:

<CodeGroup>
  ```python Python theme={"system"}
  from portkey_ai import Portkey

  portkey = Portkey(api_key="PORTKEY_API_KEY", provider="@voyage")

  embedding = portkey.embeddings.create(
      model="voyage-3",
      input="Name the tallest buildings in Hawaii"
  )

  print(embedding.data[0].embedding)
  ```

  ```javascript Node.js theme={"system"}
  import Portkey from 'portkey-ai';

  const portkey = new Portkey({
      apiKey: 'PORTKEY_API_KEY',
      provider: '@voyage'
  });

      const embedding = await portkey.embeddings.create({
      model: "voyage-3",
      input: "Name the tallest buildings in Hawaii"
      });

  console.log(embedding.data[0].embedding);
  ```
</CodeGroup>

### Rerank

Portkey supports Voyage AI's reranking models through a unified `/v1/rerank` endpoint.

```sh theme={"system"}
curl https://api.portkey.ai/v1/rerank \
  -H "Content-Type: application/json" \
  -H "x-portkey-api-key: $PORTKEY_API_KEY" \
  -d '{
    "model": "@voyage-ai-prod/rerank-2",
    "query": "What is the capital of the United States?",
    "documents": [
      "Carson City is the capital city of the American state of Nevada.",
      "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
      "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
      "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."
    ],
    "top_n": 3
  }'
```

#### Voyage-Specific Parameters

| Parameter    | Type    | Description                                                          |
| ------------ | ------- | -------------------------------------------------------------------- |
| `truncation` | boolean | Whether to truncate documents that exceed the model's context length |
| =======      |         |                                                                      |

### Reranking

Rerank documents for better search results:

<CodeGroup>
  ```python Python theme={"system"}
  from portkey_ai import Portkey

  portkey = Portkey(api_key="PORTKEY_API_KEY", provider="@voyage")

      response = portkey.post(
              "/rerank",
              model="rerank-2-lite",
              query="What is the capital of the United States?",
              documents=[
                  "Carson City is the capital city of the American state of Nevada.",
          "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean.",
          "Washington, D.C. is the capital of the United States.",
          "Capital punishment has existed in the United States since before it was a country."
              ]
          )

      print(response)
  ```

  ```javascript Node.js theme={"system"}
  import Portkey from 'portkey-ai';

  const portkey = new Portkey({
      apiKey: 'PORTKEY_API_KEY',
      provider: '@voyage'
  });

  const response = await portkey.post(
      "/rerank",
      {
          model: "rerank-2-lite",
          query: "What is the capital of the United States?",
          documents: [
              "Carson City is the capital city of the American state of Nevada.",
              "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean.",
              "Washington, D.C. is the capital of the United States.",
              "Capital punishment has existed in the United States since before it was a country."
          ]
      }
  );

  console.log(response);
  ```
</CodeGroup>

***

## Supported Models

Voyage AI offers specialized embedding and reranking models:

| Model         | Type      | Description                            |
| ------------- | --------- | -------------------------------------- |
| voyage-3      | Embedding | Latest general-purpose embedding model |
| voyage-3-lite | Embedding | Faster, lighter version                |
| voyage-code-3 | Embedding | Optimized for code                     |
| rerank-2      | Reranking | High-quality reranking                 |
| rerank-2-lite | Reranking | Faster reranking                       |

Check [Voyage AI's documentation](https://docs.voyageai.com/) for the complete model list.

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Gateway Configs" icon="sliders" href="/product/ai-gateway">
    Add fallbacks, load balancing, and more
  </Card>

  <Card title="Observability" icon="chart-line" href="/product/observability">
    Monitor and trace your Voyage requests
  </Card>

  <Card title="Caching" icon="database" href="/product/ai-gateway/cache-simple-and-semantic">
    Cache embeddings for faster responses
  </Card>

  <Card title="Metadata" icon="tag" href="/product/observability/metadata">
    Add custom metadata to requests
  </Card>
</CardGroup>

For complete SDK documentation:

<Card title="SDK Reference" icon="code" href="/api-reference/sdk/list">
  Complete Portkey SDK documentation
</Card>
