Principle:Ollama Ollama OpenAI Embeddings And Listing
| Knowledge Sources | |
|---|---|
| Domains | API_Design, NLP |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
Translation mechanisms for OpenAI-compatible embedding generation and model listing endpoints that convert between Ollama and OpenAI response formats.
Description
This principle covers two auxiliary OpenAI-compatible endpoints:
Embeddings (/v1/embeddings): Translates OpenAI embedding requests to Ollama's embed API and formats the response as an OpenAI EmbeddingList. Supports both float and base64 encoding formats.
Model Listing (/v1/models): Translates Ollama's model list into the OpenAI models list format, mapping model names to OpenAI model objects with IDs and ownership information.
Usage
Use these translation patterns when implementing auxiliary API endpoints that provide embedding and model discovery capabilities in an OpenAI-compatible format.
Theoretical Basis
Embedding Translation:
- Receive OpenAI embedding request (model, input text, encoding_format)
- Translate to Ollama EmbedRequest
- Get embedding vectors from Ollama
- Format as OpenAI EmbeddingList with index, embedding, and usage
Model Listing Translation:
- Receive request at /v1/models
- Get model list from Ollama (/api/tags)
- Map each model to OpenAI Model object (id, object, owned_by)