@@ -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
400400To use the OpenRouter API, you need to set the environment variable `OPENROUTER_API_KEY`.
401401You 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+
418439You can find the full list of models supported by OpenRouter [here](https://openrouter.ai/models).
419440
420441# ## vLLM
0 commit comments