- Search LightOn for the passages most relevant to the user’s question.
- Pack those passages into the model’s context window.
- Call the OVHcloud model to generate an answer grounded in the retrieved content.
Prerequisites
- A
LIGHTON_API_KEY, available in the Console → API Keys section. - An OVHcloud AI Endpoints access token, available in the OVHcloud Control Panel under Public Cloud → AI Endpoints. Store it as
OVH_AI_ENDPOINTS_ACCESS_TOKEN. - At least one workspace with indexed documents on LightOn.
Installation
openai package is used here only for its client; OVHcloud’s /chat/completions endpoint is fully compatible with it.
Full example
LightOn search as a tool
Instead of always searching before calling the model, you can expose LightOn search as a tool and let the model decide when to call it. The model issues alighton_search tool call when it needs context; your code executes the search and feeds the results back; the model then produces a final answer.
Scoping retrieval to a workspace
Passworkspace_id to limit search to a specific workspace. This is useful in multi-tenant products where each customer’s data lives in a dedicated workspace.
Choosing a model
OVHcloud’s catalog includes several hosted models. Pass the model name to themodel parameter:
You can list the models available to your token at any time:
Streaming responses
OVHcloud’s endpoint supports streaming. Enable it by passingstream=True and iterating over the response:
A note on reasoning models
Some OVHcloud models (for exampleQwen3-32B and Qwen3.6-27B) are reasoning models. When called through the raw HTTP API they may return their chain of thought under a reasoning field and the final answer under content. The openai client used in the examples above surfaces the final answer in choices[0].message.content as usual, so no special handling is needed; read message.reasoning only if you want to inspect the thinking trace.