Skip to content
Help guide the future of agentgateway — Take the survey

Embeddings

Verified : Automated tests passed for: Configuration files: The configuration files on this page were checked against their schema.
Page as Markdown

Send embedding requests through agentgateway using the OpenAI-compatible Embeddings API.

The Embeddings API (/v1/embeddings) creates vector representations of text that you can use for search, retrieval, clustering, and other semantic workflows.

About

Agentgateway supports the OpenAI-compatible Embeddings API. Requests to /v1/embeddings are routed to your configured provider while agentgateway applies the same routing, authentication, observability, and policy framework that you use for other LLM traffic.

Route type configuration

In the simplified llm configuration, agentgateway automatically maps /v1/embeddings requests to the embeddings route type, so no explicit route configuration is required.

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
  models:
  - name: "*"
    provider: openAI
    params:
      apiKey: "$OPENAI_API_KEY"

To configure the route type explicitly, use the gateways and routes format and set the embeddings route type in the policies.ai.routes map.

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
gateways:
  default:
    port: 4000
routes:
- backends:
  - ai:
      name: openai
      provider:
        openAI: {}
  policies:
    ai:
      routes:
        "/v1/embeddings": "embeddings"
    backendAuth:
      key: "$OPENAI_API_KEY"

Without the embeddings entry, agentgateway parses a /v1/embeddings request as a chat completion. The request fails with a 400 response. The error message contains missing field `messages` .

Note

For detailed information about model routing and configuration modes, see Model routing and aliases.

Using the API

Send a request to the /v1/embeddings endpoint. The response includes an embedding vector for each input item.

curl 'http://localhost:4000/v1/embeddings' \
--header 'Content-Type: application/json' \
--data '{
  "model": "text-embedding-3-small",
  "input": [
    "agentgateway routes LLM traffic",
    "embeddings turn text into vectors"
  ]
}'

Amazon Bedrock Titan models

Amazon Bedrock Titan text embedding models take one string for each request. A request with an input array fails with a 400 response and the message Titan requires a single string input. Set encoding_format to float in requests to Titan. With base64, the response has an empty embedding. The OpenAI Python SDK sends base64 unless you set the format.

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate ↵ select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.