Skip to content

Commit 94c88b9

Browse files
committed
Update doc for OpenRouter embedding
1 parent fcfc93a commit 94c88b9

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

docs/docs/ai/llm.mdx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ We support the following types of LLM APIs:
2626
| [Anthropic](#anthropic) | `LlmApiType.ANTHROPIC` |||
2727
| [Voyage](#voyage) | `LlmApiType.VOYAGE` |||
2828
| [LiteLLM](#litellm) | `LlmApiType.LITE_LLM` |||
29-
| [OpenRouter](#openrouter) | `LlmApiType.OPEN_ROUTER` || |
29+
| [OpenRouter](#openrouter) | `LlmApiType.OPEN_ROUTER` || |
3030
| [vLLM](#vllm) | `LlmApiType.VLLM` |||
3131
| [Bedrock](#bedrock) | `LlmApiType.BEDROCK` |||
3232

@@ -400,7 +400,7 @@ You can find the full list of models supported by LiteLLM [here](https://docs.li
400400
To use the OpenRouter API, you need to set the environment variable `OPENROUTER_API_KEY`.
401401
You can generate the API key from [here](https://openrouter.ai/settings/keys).
402402

403-
A spec for OpenRouter looks like this:
403+
A text generation spec for OpenRouter looks like this:
404404

405405
<Tabs>
406406
<TabItem value="python" label="Python" default>
@@ -415,6 +415,27 @@ cocoindex.LlmSpec(
415415
</TabItem>
416416
</Tabs>
417417

418+
OpenRouter also supports some text embedding models. Note that for OpenRouter embedding
419+
models, you need to explicitly provide the `output_dimension` parameter in the spec.
420+
Here's how you can define the spec to use an OpenRouter embedding model:
421+
422+
<Tabs>
423+
<TabItem value="python" label="Python" default>
424+
425+
```python
426+
cocoindex.functions.EmbedText(
427+
api_type=cocoindex.LlmApiType.OPEN_ROUTER,
428+
model="openai/text-embedding-3-small",
429+
# Task type for embedding model
430+
task_type="SEMANTICS_SIMILARITY",
431+
# Required: the number of output dimensions for the embedding model
432+
output_dimension=1536,
433+
)
434+
```
435+
436+
</TabItem>
437+
</Tabs>
438+
418439
You can find the full list of models supported by OpenRouter [here](https://openrouter.ai/models).
419440

420441
### vLLM

0 commit comments

Comments
 (0)