Python Ollama embeddings with Poetry¶
Embeddings example
This example shows the smallest OpenAI Python SDK setup for calling POST /v1/embeddings through LunarGate into a local Ollama model.
Use this example when:
- you want the smallest possible embeddings example
- you want to test local Ollama with LunarGate before building RAG
- you want to confirm that your gateway exposes
/v1/embeddings
What it demonstrates¶
OpenAI(base_url=...)pointed at LunarGate- one
client.embeddings.create(...)request - local Ollama as the upstream embedding provider
- a minimal route matching
/v1/embeddings
Run it¶
Make sure Ollama has the embedding model:
Start the gateway in a separate terminal:
Then run the client:
What to inspect¶
main.pyfor the OpenAI SDK embeddings callconfig-simple.yaml.examplefor the/v1/embeddingsrouteREADME.mdfor local Ollama requirements
Why this example matters¶
This is the shortest path from:
- local embeddings in Ollama
To:
- OpenAI-compatible embeddings through LunarGate
That makes it the right smoke test before you build semantic search, retrieval, or RAG on top.