Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
64dab00
Work on docs
tgahunia05 Jun 13, 2025
4ab7294
work on docs
tgahunia05 Jun 13, 2025
6a902ef
work on docs
tgahunia05 Jun 13, 2025
cfd34e5
Use similar language to other extension docs
tgahunia05 Jun 13, 2025
3458e05
Update fcn signature and region/model related notes
tgahunia05 Jun 16, 2025
d35ae0e
NIT
tgahunia05 Jun 16, 2025
aea7f46
Update to reflect region specification
tgahunia05 Jun 18, 2025
41648be
Provide example with vector ext
tgahunia05 Jun 18, 2025
38c78f2
Add result to synergy example
tgahunia05 Jun 18, 2025
5d396d4
Update docs with PR feedback
tgahunia05 Jun 20, 2025
cc530e4
Update src/content/docs/extensions/llm.mdx
tgahunia05 Jun 23, 2025
c916531
Update src/content/docs/extensions/llm.mdx
tgahunia05 Jun 23, 2025
6ad5d4c
Update src/content/docs/extensions/llm.mdx
tgahunia05 Jun 23, 2025
1453626
Update src/content/docs/extensions/llm.mdx
tgahunia05 Jun 23, 2025
781555d
Update src/content/docs/extensions/llm.mdx
tgahunia05 Jun 23, 2025
33e6ae3
Update src/content/docs/extensions/llm.mdx
tgahunia05 Jun 23, 2025
d6fe678
Update src/content/docs/extensions/llm.mdx
tgahunia05 Jun 23, 2025
331dd3e
Apply PR feedback
tgahunia05 Jun 23, 2025
cde2178
Retire arg: type form to document syntax
tgahunia05 Jun 23, 2025
dd007e0
NIT
tgahunia05 Jun 23, 2025
3c72603
Fix incorrect provider in example
tgahunia05 Jun 23, 2025
15901d3
Apply PR feedback
tgahunia05 Jun 23, 2025
771e9dc
Copyedit
sdht0 Jun 25, 2025
0fdf4a9
correct invalid optional param syntax, add env var example
tgahunia05 Jun 25, 2025
ba5d1cc
Need to init conn before using it
tgahunia05 Jun 25, 2025
e71a2aa
Add one more example where create embedding can be used, update filte…
tgahunia05 Jun 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export default defineConfig({
{ label: 'JSON', link: '/extensions/json' },
{ label: 'Neo4j', link: '/extensions/neo4j', badge: { text: 'New' }},
{ label: 'Vector search', link: '/extensions/vector'},
{ label: 'LLM', link: '/extensions/llm', badge: { text: 'New' }},
],
},
],
Expand Down
109 changes: 109 additions & 0 deletions src/content/docs/extensions/llm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
title: "LLM Extension"
---

import { Tabs, TabItem } from '@astrojs/starlight/components';

The **LLM extension** provides a `CREATE_EMBEDDING` function for creating text embeddings using API calls to supported providers.

We currently support the following providers:

* [OpenAI](https://platform.openai.com/docs/guides/embeddings)
* [Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html)
* [Google Vertex](https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-text-embeddings)
* [Google Gemini](https://ai.google.dev/gemini-api/docs/embeddings)
* [Voyage AI](https://docs.voyageai.com/docs/embeddings)
* [Ollama](https://ollama.com/blog/embedding-models)
---

## Usage

Install and load the extension using the following commands:

```sql
INSTALL llm;
LOAD llm;
```

### Configuration

To allow API calls to the providers, you must set the appropriate environment variables:

| Provider | Required Environment Variables |
| --- | --- |
| `amazon-bedrock` | `AWS_ACCESS_KEY`, `AWS_SECRET_ACCESS_KEY` |
| `google-vertex` | `GOOGLE_CLOUD_PROJECT_ID`, `GOOGLE_VERTEX_ACCESS_KEY` |
| `google-gemini` | `GOOGLE_GEMINI_API_KEY` |
| `open-ai` | `OPENAI_API_KEY` |
| `voyage-ai` | `VOYAGE_API_KEY` |
| `ollama` | None, but expects access to `http://localhost:11434` |

See how to set environment variables below:

<Tabs>
<TabItem value="cypher" label="Cypher">

```bash
# Set the OpenAI API key
export OPENAI_API_KEY=sk-proj-key
```

</TabItem>

<TabItem value="python" label="Python">
```python
os.environ["OPENAI_API_KEY"] = "sk-proj-key"
#...
```

</TabItem>
</Tabs>

## Creating embeddings

You can generate text embeddings using the `CREATE_EMBEDDING` function. The function returns a `LIST[FLOAT]` type.

```sql
CALL CREATE_EMBEDDING(
'prompt', // The input text to embed.
'provider', // The embedding provider. E.g., `'open-ai'`.
'model', // The identifier of the embedding model. E.g., `'text-embedding-3-small'`.
// Optional parameters, if supported by the provider.
);
```

### Optional parameters

| Option |Type| Description |
|--------|------|-------|
| dimensions |`INT64`| The size of the embedding vector, if supported by the provider. Currently only `'open-ai'`, `'google-vertex'`, and `'voyage-ai'` support this option. |
| region |`STRING`| A region or endpoint, if supported by the provider. E.g., `'us-east-1'` for `'amazon-bedrock'`. |

:::note[Note]
If an unsupported model, dimension, or region is specified, the API call to the provider will fail. Check the provider's API documentation for the currently supported options.
:::

### Examples

```sql
CALL CREATE_EMBEDDING("Hello world", "open-ai", "text-embedding-3-small");

CALL CREATE_EMBEDDING("Hello world", "ollama", "nomic-embed-text");

CALL CREATE_EMBEDDING("Hello world", "google-gemini", "gemini-embedding-exp-03-07");
```

With optional parameters:

```sql
CALL CREATE_EMBEDDING("Hello world", "voyage-ai", "voyage-3-large", 512);

CALL CREATE_EMBEDDING("Hello world", "amazon-bedrock", "amazon.titan-embed-text-v1", "us-east-1");

CALL CREATE_EMBEDDING("Hello world", "google-vertex", "gemini-embedding-001", 256, "us-east1");
```
---

## Storing embeddings in a vector index

The embedding function can be used with the `vector` extension. The example in the [vector docs](/extensions/vector) shows how the `CREATE_EMBEDDING` function can be used to create the embeddings needed for the vector index directly in Kuzu.
Loading