Embeddings API

FastRouter.ai supports a unified Embeddings API to generate high-quality vector representations for your text using supported model providers like OpenAI.

Supported Models

openai/text-embedding-3-small

Fast and lightweight embedding model

openai/text-embedding-3-large

High-quality embeddings for nuanced tasks

openai/text-embedding-ada-002

Most cost-effective embedding model

google/gemini-embedding-001

Google's versatile embedding model for text and multimodal tasks

deepinfra/intfloat-e5-base-v2

Efficient, high-performance embedding model based on E5 architecture from DeepInfra

Parameters

Field
Type
Description

model

string

The fully qualified model slug. See Supported Models above.

input

string or string[]

The input text or array of texts to embed. Maximum length depends on the model used.

dimensions

integer

Optional. The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.

Endpoint

POST https://go.fastrouter.ai/v1/embeddings

Request Format

Send a prompt input with an optional dimensions parameter to generate embeddings.

Request Example

{
  "model": "openai/text-embedding-3-large",
  "input": "What is node JS?",
  "dimensions": 4  
}

Sample Response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, 0.0492, ..., -0.0187]
    }
  ],
  "model": "openai/text-embedding-3-large",
  "usage": {
    "prompt_tokens": 5,
    "total_tokens": 5
  }
}

Python Example

You can use the OpenAI Python SDK with FastRouter's base URL to generate embeddings. Here's a sample script:

from openai import OpenAI

client = OpenAI(
    base_url="https://go.fastrouter.ai/v1",  # FastRouter base URL
    api_key="FASTROUTER_API_KEY",  # Replace with your actual API key
)

embeddings = client.embeddings.create(
    input="Your text string goes here",
    model="text-embedding-3-large",
    dimensions=4
)

print("Embeddings:", embeddings)

Last updated