## 1. Project Overview & Quickstart (Kiln-AI/Kiln)

## File: README.md

<h3 align="center">
  A free app and open-source library to build better AI products.
</h3>










## What is Kiln?

Kiln is a workbench for the full AI development loop: evals, optimization, prompts, RAG, fine-tuning, synthetic data, agents, and tools - all working together. The desktop app lets your whole team contribute (PMs, subject-experts, and QA can rate outputs and add data without writing code). The MIT-licensed Python library ships the same tasks to production. Runs locally - bring your own API keys, or go fully offline with Ollama.

## Highlights

### Iterate, optimize, and collaborate

- 🖥️ [**Intuitive app**](https://kiln.tech/download) - Easy-to-use apps for Mac, Windows, and Linux. One-click install.
- 📊 [**Eval Builder**](https://docs.kiln.tech/docs/evaluations) - Auto-generate evals (judge + synthetic eval dataset), and align to your preference in ~10 minutes.
- 🚀 [**Auto-Optimize**](https://docs.kiln.tech/docs/prompts/automatic-prompt-optimizer) - Automatically find the best way to run your AI task, optimizing prompt, model selection, tools, skills, subagents, parameters, and more.
- 💬 [**AI Assistant**](https://docs.kiln.tech) - Your AI data-science partner. Kiln Assistant proposes improvements, optimizes prompts, runs experiments, creates evals, and more.
- 🤝 [**Git-native collaboration**](https://docs.kiln.tech/docs/collaboration) - The app syncs to Git automatically — even for teammates who don't know what Git is.

### Build & ship agents

- 🔍 [**RAG**](https://docs.kiln.tech/docs/documents-and-search-rag) - Drag-and-drop docs (PDF, image, video, audio) to create a RAG. Auto-generated RAG evals from your own documents.
- 🤖 [**Subagents**](https://docs.kiln.tech/docs/agents) - Compose multi-agent hierarchies. Each runs in its own focused context window.
- 🪄 [**Synthetic Data Generation**](https://docs.kiln.tech/docs/synthetic-data-generation) - Generate data for evals or fine-tuning in minutes.
- 🎛️ [**Fine-Tuning**](https://docs.kiln.tech/docs/fine-tuning-guide) - Zero-code fine-tuning across 60+ models (Qwen, Llama, GPT, Gemini, …) on Fireworks, Together, and Vertex. Serverless deployment included.
- 🐍 [**Open Python library**](https://docs.kiln.tech/developers/python-library-quickstart) - Agents built in the app can be deployed to production. MIT open-source.
- 🧰 [**…and more**](https://docs.kiln.tech) - Tools & MCP, Skills, structured outputs, reasoning models, model library (190+ tested).

## App Quickstart

Get started in minutes - one-click install.

Download Kiln Desktop for macOS, Windows, or Linux, then follow the [5-minute quickstart](https://docs.kiln.tech/getting-started/quickstart) to run your first task.

[](https://kiln.tech/download) [](https://kiln.tech/download) [](https://kiln.tech/download)

Prefer to start in code? See the [Python library quickstart](https://docs.kiln.tech/developers/python-library-quickstart).

## Demo

[Watch a 2-minute overview](https://kiln.tech#demo), or our [end-to-end project demo (20 minutes)](https://docs.kiln.tech/docs/end-to-end-project-demo).

## Why Kiln?

Most AI tooling forces a tradeoff: a code-only framework that covers one slice (orchestration *or* evals *or* RAG), or a paid SaaS that locks in your data and can't be extended. Kiln is a free, local-first workbench where a single task and dataset flow through evals, prompt optimization, fine-tuning, RAG, agents, and synthetic data — all in one tool.

- **One dataset, every technique.** Define a task once. Eval it, optimize the prompt, fine-tune a model, generate synthetic data, add RAG — all against the same dataset, with results that compound across stages.

- **Track every axis. Move fast. Don't regress.** Keeping agents running well is hard — a prompt change quietly regresses behavior three steps downstream; a model upgrade improves five things and breaks two. Kiln tracks quality across every dimension you care about, so you iterate without breaking what already works.

  

- **Optimization, not just evaluation.** Other tools tell you how a prompt scores, but not how to fix it. Kiln's Auto-Optimize searches across hundreds of prompt mutations and models to find what works best for every eval dimension.

- **GUI for the whole team, library for engineers.** Kiln's desktop app lets PMs rate outputs, SMEs add training examples, and QA flag regressions — without a terminal. Engineers ship the same tasks via an MIT-licensed Python library. Data scientists can use the library in notebooks and experiments.

- **Local-first.** Most AI platforms are SaaS-only. Kiln runs entirely on your machine. Bring your own API keys, or go fully offline with Ollama. Your data never leaves your control. Team-sync is provided via Git infrastructure you already own.

- **190+ models tested across every provider.** Skip the guesswork — we've tested every model's capabilities across all major providers. OpenAI, Anthropic, Gemini, Bedrock, Ollama, OpenRouter, Fireworks, Groq, any OpenAI-compatible endpoint, and more. Swap models with confidence.

## Open-source Python Library

Build AI tasks in the app. Deploy with the open-source library. Same engine, same project files, no rewrite. The MIT-licensed `kiln-ai` library is the same library used in the app. Load Kiln projects, run tasks, build fine-tunes, work in notebooks, integrate Pandas/Polars dataframes, and more.

```bash
pip install kiln-ai
```

[📚 Library docs](https://docs.kiln.tech/developers/python-library-quickstart) · [REST API](https://docs.kiln.tech/developers/rest-api) · [PyPI](https://pypi.org/project/kiln-ai/)

## Docs

Full docs at [docs.kiln.tech](https://docs.kiln.tech). Common starting points:

- [Quickstart](https://docs.kiln.tech/getting-started/quickstart) — run your first task in 5 minutes
- [Evals](https://docs.kiln.tech/docs/evaluations)
- [Auto-Optimize](https://docs.kiln.tech/docs/prompts/automatic-prompt-optimizer)
- [RAG](https://docs.kiln.tech/docs/documents-and-search-rag)
- [Agents](https://docs.kiln.tech/docs/agents)
- [Fine-Tuning](https://docs.kiln.tech/docs/fine-tuning-guide)
- [Python Library](https://docs.kiln.tech/developers/python-library-quickstart)
- [End-to-end project demo](https://docs.kiln.tech/docs/end-to-end-project-demo) (20-min video)

## Community

- Chat with the community on [Discord](https://kiln.tech/discord).
- Subscribe to the [newsletter](https://kiln.tech/blog) for new features.
- File issues, request features, or open a discussion on [GitHub](https://github.com/Kiln-AI/Kiln/issues).

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and contribution guidelines.

## License & Trademarks

Kiln's core Python library and REST server are [MIT-licensed](libs/core/LICENSE.txt). The desktop app is [source-available](app), free to use, and built on the [fair-code](https://faircode.io) model — so Kiln stays free for individuals while remaining sustainable.

Datasets are open JSON. You own and control your datasets.

[Kiln Pro](https://kiln.tech/pricing) is our service that adds the AI Assistant, Auto-Optimize, and the Eval Builder. It's opt-in, and the core Kiln app remains fully functional without it.

The Kiln name and logos are trademarks of Chesterfield Laboratories Inc.

Copyright 2024 — Chesterfield Laboratories Inc.

---

## File: app/desktop/dmg/README.md

# Make a MacOS DMG

Weird node 20 workaround for this: https://github.com/sindresorhus/create-dmg

Each time it should just be:

```
create-dmg Kiln.app
# then rename the output dmg to Kiln.MacOS.Intel.dmg or Kiln.MacOS.AppleSilicon.M-Processor.dmg
```

Env Setup while node 20 is required:

- `nvm use 20`
- `npm install create-dmg`
- `create-dmg Kiln.app`
- rename the output dmg to Kiln.MacOS.Intel.dmg or Kiln.MacOS.AppleSilicon.M-Processor.dmg
- `nvm use 23`

---

## File: app/desktop/README.md

# Desktop Apps

## MacOS Environment Setup

UV python doesn't include TK/TCL [yet](https://github.com/astral-sh/uv/issues/7036). Instead, we install system python including TK/TCL, and tell UV venv to use system python.

```
# Install python 3.13 and python-tk 3.13 with homebrew
brew install python-tk@3.13
brew install python@3.13

# check uv can see it hoembrew version
uv python list --python-preference only-system

# setup 3.13 uv-managed venv with system (homebrew) python 3.13
uv venv --python 3.13 --python-preference only-system

# Check it worked
uv run python --version

# Run desktop
uv run python -m app.desktop.desktop
```

## Building the Desktop App

Typically building desktop apps are done in a CI/CD pipeline, but if you need to build the desktop app locally, you can do so with:

```bash
cd app/desktop
uv run ./build_desktop_app.sh
```

## MacOS Code Signing

Easy way, but just signs with personal ID for local development: `codesign --force --deep -s - kiln.app`

Sign with a developer ID (should only be done for official releases by Kiln team):

1. Get developer ID name: `security find-identity -v -p codesigning`
2. Run `codesign --force --deep -s "Developer ID Application: YOUR NAME (XXXXXXXX)" kiln.app`

---

## File: libs/server/README.md

# Kiln AI REST Server

[](https://pypi.org/project/kiln-server)
[](https://pypi.org/project/kiln-server)

---

## About Kiln AI

Learn more about Kiln AI at [kiln.tech](https://kiln.tech)

This package is the Kiln AI server package. There is also a separate desktop application and python library package.

Github: [github.com/Kiln-AI/kiln](https://github.com/Kiln-AI/kiln)

## Installation

We suggest installing with uv:

```console
uv tool install kiln_server
```

## REST API Docs

Our OpenAPI docs: [https://kiln-ai.github.io/Kiln/kiln_server_openapi_docs/index.html](https://kiln-ai.github.io/Kiln/kiln_server_openapi_docs/index.html)

## Running the server

After installing, run:

```console
kiln_server
```

## kiln_server Command Options

```
usage: kiln_server [-h] [--host HOST] [--port PORT] [--log-level LOG_LEVEL] [--auto-reload AUTO_RELOAD]

Run the Kiln AI REST Server.

options:
  -h, --help            show this help message and exit
  --host HOST           Host for network transports.
  --port PORT           Port for network transports.
  --log-level LOG_LEVEL
                        Log level for the server when using network transports.
  --auto-reload AUTO_RELOAD
                        Enable auto-reload for the server.
```

## Using the server in another FastAPI app

See server.py for examples, but you can connect individual API endpoints to your app like this:

```python
from kiln_server.project_api import connect_project_api

app = FastAPI()
connect_project_api(app)
```

## Kiln MCP Server

Also included in this package is a MCP server for serving Kiln tools.

See [it's README](./kiln_server/mcp/README.md) for details.

---

## File: libs/core/README.md

# Kiln AI Core Library



[](https://pypi.org/project/kiln-ai)
[](https://pypi.org/project/kiln-ai)
[](https://kiln-ai.github.io/Kiln/kiln_core_docs/index.html)

---

## Installation

```console
pip install kiln_ai
```

## About

This package is the Kiln AI core library. There is also a separate desktop application and server package. Learn more about Kiln AI at [kiln.tech](https://kiln.tech) and on Github: [github.com/Kiln-AI/kiln](https://github.com/Kiln-AI/kiln).

# Guide: Using the Kiln Python Library

In this guide we'll walk common examples of how to use the library.

## Documentation

The library has a [comprehensive set of docs](https://kiln-ai.github.io/Kiln/kiln_core_docs/index.html).

## Table of Contents

- [Connecting AI Providers](#connecting-ai-providers-openai-openrouter-ollama-etc)
- [Using the Kiln Data Model](#using-the-kiln-data-model)
  - [Understanding the Kiln Data Model](#understanding-the-kiln-data-model)
  - [Datamodel Overview](#datamodel-overview)
  - [Load a Project](#load-a-project)
  - [Run a Kiln Task from Python](#run-a-kiln-task-from-python)
  - [Load an Existing Dataset into a Kiln Task Dataset](#load-an-existing-dataset-into-a-kiln-task-dataset)
  - [Using your Kiln Dataset in a Notebook or Project](#using-your-kiln-dataset-in-a-notebook-or-project)
  - [Using Kiln Dataset in Pandas](#using-kiln-dataset-in-pandas)
  - [Building and Running a Kiln Task from Code](#building-and-running-a-kiln-task-from-code)
  - [Tagging Task Runs Programmatically](#tagging-task-runs-programmatically)
  - [Adding Custom Model or AI Provider from Code](#adding-custom-model-or-ai-provider-from-code)
- [Taking Kiln RAG to production](#taking-kiln-rag-to-production)
  - [Load a LlamaIndex Vector Store](#load-a-llamaindex-vector-store)
  - [Example: LanceDB Cloud](#example-lancedb-cloud)
  - [Deploy RAG without LlamaIndex](#deploy-rag-without-llamaindex)
- [Connecting to Telemetry / MLOps](#connecting-to-telemetry--mlops-opentelemetry-braintrust-etc)
- [Full API Reference](#full-api-reference)

## Installation

```bash
pip install kiln-ai
```

## Connecting AI Providers (OpenAI, OpenRouter, Ollama, etc)

The easiest way to connect AI providers is to use the Kiln app UI. Once connected in the UI, credentials will be stored to `~/.kiln_ai/settings.yaml`, which will be available to the library.

For configuring credentials from code or connecting custom servers/model, see [Adding Custom Model or AI Provider from Code](#adding-custom-model-or-ai-provider-from-code).

## Using the Kiln Data Model

### Understanding the Kiln Data Model

Kiln projects are simply a directory of files (mostly JSON files with the extension `.kiln`) that describe your project, including tasks, runs, and other data.

This dataset design was chosen for several reasons:

- Git compatibility: Kiln project folders are easy to collaborate on in git. The filenames use unique IDs to avoid conflicts and allow many people to work in parallel. The files are small and easy to compare using standard diff tools.
- JSON allows you to easily load and manipulate the data using standard tools (pandas, polars, etc)

The Kiln Python library provides a set of Python classes that which help you easily interact with your Kiln dataset. Using the library to load and manipulate your dataset is the fastest way to get started, and will guarantees you don't insert any invalid data into your dataset. There's extensive validation when using the library, so we recommend using it to load and manipulate your dataset over direct JSON manipulation.

### Datamodel Overview

Here's a high level overview of the Kiln datamodel. A project folder will reflect this nested structure:

- Project: a Kiln Project that organizes related tasks
  - Task: a specific task including prompt instructions, input/output schemas, and requirements
    - TaskRun: a sample (run) of a task including input, output and human rating information
    - Finetune: configuration and status tracking for fine-tuning models on task data
    - Prompt: a prompt for this task
    - DatasetSplit: a frozen collection of task runs divided into train/test/validation splits

### Load a Project

Assuming you've created a project in the Kiln UI, you'll have a `project.kiln` file in your `~/Kiln Projects/Project Name` directory.

```python
from kiln_ai.datamodel import Project

project = Project.load_from_file("path/to/your/project.kiln")
print("Project: ", project.name, " - ", project.description)

# List all tasks in the project, and their dataset sizes
tasks = project.tasks()
for task in tasks:
    print("Task: ", task.name, " - ", task.description)
    print("Total dataset size:", len(task.runs()))
```

### Run a Kiln Task from Python

If you've already created a Kiln task and want to run it as part of a Python app you can follow this example.

**Step 1: Export your Kiln task/project**

You can run any Kiln task from code using it's project file/folder on disk. However, these folders can contain thousands of files relating to past runs and evals, which is more than you probably want to deploy to a service. Only a few of these files are needed for running the task: you can export a minimal project folder with on the necessary files to run a task by running our CLI:

```bash
uvx kiln_ai package_project "/path/to/your/project.kiln" -t TASK_ID_TO_EXPORT
```

**Step 2: Run Kiln Task from Code**

Prerequisites:

- Already have a Kiln Task created and saved to disk at `TASK_PATH`. It doesn't matter if you created it using the Kiln app, the Kiln library, or exported it using the command above.
- Set a default run configuration in the Kiln UI specifying how to run the task: model, AI provider, etc. Alternatively you can create a RunConfigProperties instance in code.
- Set up any API keys required for the task. If running on the same machine as the Kiln app, these will already be saved in `~/.kiln_ai/settings.yaml` and will be loaded automatically. If running on a server, you can set the required environment variables (see `libs/core/kiln_ai/utils/config.py` for a list).
- If your task uses RAG, ensure you have run search indexing on this machine with the Kiln UI or via the library.

```python
from kiln_ai.adapters.adapter_registry import adapter_for_task
from kiln_ai.datamodel.task import Task

async def run_kiln_task(input: str) -> dict[str, Any] | str:
    # Load your task from it's path on the filesystem
    task = Task.load_from_file(TASK_PATH)
    # Here we get the default run config from the task, which you can set in the UI. Alternatively you could pass a RunConfigProperties object with parameters like the model, temperature, etc.
    run_config = next(c for c in task.run_configs() if c.id == task.default_run_config_id)

    # An adapter can run a task
    adapter = adapter_for_task(
        task,
        run_config_properties=run_config.run_config_properties,
    )

    task_run, run_output = await adapter.invoke_returning_run_output(input)

    # Optional: can inspect the task run to see usage data (cost, tokens, etc.)
    #print(f"Task run cost: {task_run.usage.cost}")

    return run_output.output
```

### Load an Existing Dataset into a Kiln Task Dataset

If you already have a dataset in a file, you can load it into a Kiln project.

**Important**: Kiln will validate the input and output schemas, and ensure that each datapoint in the dataset is valid for this task.

- Plaintext input/output: ensure "output_json_schema" and "input_json_schema" not set in your Task definition.
- JSON input/output: ensure "output_json_schema" and "input_json_schema" are valid JSON schemas in your Task definition. Every datapoint in the dataset must be valid JSON fitting the schema.

Here's a simple example of how to load a dataset into a Kiln task:

```python

import kiln_ai
import kiln_ai.datamodel

# Created a project and task via the UI and put its path here
task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
task = kiln_ai.datamodel.Task.load_from_file(task_path)

# Add data to the task - loop over you dataset and run this for each item
item = kiln_ai.datamodel.TaskRun(
    parent=task,
    input='{"topic": "AI"}',
    output=kiln_ai.datamodel.TaskOutput(
        output='{"setup": "What is AI?", "punchline": "content_here"}',
    ),
)
item.save_to_file()
print("Saved item to file: ", item.path)
```

And here's a more complex example of how to load a dataset into a Kiln task. This example sets the source of the data (human in this case, but you can also set it be be synthetic), the created_by property, and a 5-star rating.

```python
import kiln_ai
import kiln_ai.datamodel

# Created a project and task via the UI and put its path here
task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
task = kiln_ai.datamodel.Task.load_from_file(task_path)

# Add data to the task - loop over you dataset and run this for each item
item = kiln_ai.datamodel.TaskRun(
    parent=task,
    input='{"topic": "AI"}',
    input_source=kiln_ai.datamodel.DataSource(
        type=kiln_ai.datamodel.DataSourceType.human,
        properties={"created_by": "John Doe"},
    ),
    output=kiln_ai.datamodel.TaskOutput(
        output='{"setup": "What is AI?", "punchline": "content_here"}',
        source=kiln_ai.datamodel.DataSource(
            type=kiln_ai.datamodel.DataSourceType.human,
            properties={"created_by": "Jane Doe"},
        ),
        rating=kiln_ai.datamodel.TaskOutputRating(
            value=5,
            type=kiln_ai.datamodel.datamodel_enums.five_star,
        ),
    ),
)
item.save_to_file()
print("Saved item to file: ", item.path)
```

### Using your Kiln Dataset in a Notebook or Project

You can use your Kiln dataset in a notebook or project by loading the dataset into a pandas dataframe.

```python
import kiln_ai
import kiln_ai.datamodel

# Created a project and task via the UI and put its path here
task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
task = kiln_ai.datamodel.Task.load_from_file(task_path)

runs = task.runs()
for run in runs:
    print(f"Input: {run.input}")
    print(f"Output: {run.output.output}")

print(f"Total runs: {len(runs)}")
```

### Using Kiln Dataset in Pandas

You can also use your Kiln dataset in a pandas dataframe, or a similar script for other tools like polars.

```python
import glob
import json
import pandas as pd
from pathlib import Path

task_dir = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator"
dataitem_glob = task_dir + "/runs/*/task_run.kiln"

dfs = []
for file in glob.glob(dataitem_glob):
    js = json.loads(Path(file).read_text())

    df = pd.DataFrame([{
        "input": js["input"],
        "output": js["output"]["output"],
    }])

    # Alternatively: you can use pd.json_normalize(js) to get the full json structure
    # df = pd.json_normalize(js)
    dfs.append(df)
final_df = pd.concat(dfs, ignore_index=True)
print(final_df)
```

### Building and Running a Kiln Task from Code

```python
# Step 1: Create or Load a Task -- choose one of the following 1.A or 1.B

# Step 1.A: Optionally load an existing task from disk
# task = datamodel.Task.load_from_file("path/to/task.kiln")

# Step 1.B: Create a new task in code, without saving to disk.
task = datamodel.Task(
    name="test task",
    instruction="Tell a joke, given a subject.",
)
# replace with a valid JSON schema https://json-schema.org for your task (json string, not a python dict).
# Or delete this line to use plaintext output
task.output_json_schema = json_joke_schema

# Step 2: Create an Adapter to run the task, with a specific model and provider
adapter = adapter_for_task(task, model_name="llama_3_1_8b", provider="groq")

# Step 3: Invoke the Adapter to run the task
task_input = "cows"
response = await adapter.invoke(task_input)
print(f"Output: {response.output.output}")

# Step 4 (optional): Load the task from disk and print the results.
#  This will only work if the task was loaded from disk, or you called task.save_to_file() before invoking the adapter (ephemeral tasks don't save their result to disk)
task = datamodel.Task.load_from_file(tmp_path / "test_task.kiln")
for run in task.runs():
    print(f"Run: {run.id}")
    print(f"Input: {run.input}")
    print(f"Output: {run.output}")

```

## Tagging Task Runs Programmatically

You can also tag your Kiln Task runs programmatically:

```py
# Load your Kiln Task from disk
task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
task = kiln_ai.datamodel.Task.load_from_file(task_path)

for run in task.runs():
    # Parse the task output from JSON
    output = json.loads(run.output.output)

    # Add a tag if the punchline is unusually short
    if len(output["punchline"]) < 100:
        run.tags.append("very_short")
        run.save_to_file()  # Persist the updated tags
```

### Adding Custom Model or AI Provider from Code

You can add additional AI models and providers to Kiln.

See our docs for more information, including how to add these from the UI:

- [Custom Models From Existing Providers](https://docs.kiln.tech/docs/models-and-ai-providers#custom-models-from-existing-providers)
- [Custom OpenAI Compatible Servers](https://docs.kiln.tech/docs/models-and-ai-providers#custom-openai-compatible-servers)

You can also add these from code. The kiln_ai.utils.Config class helps you manage the Kiln config file (stored at `~/.kiln_ai/settings.yaml`):

```python
# Adding an OpenAI compatible provider
name = "CustomOllama"
base_url = "http://localhost:1234/api/v1"
api_key = "12345"
providers = Config.shared().openai_compatible_providers or []
existing_provider = next((p for p in providers if p["name"] == name), None)
if existing_provider:
    # skip since this already exists
    return
providers.append(
    {
        "name": name,
        "base_url": base_url,
        "api_key": api_key,
    }
)
Config.shared().openai_compatible_providers = providers
```

```python
# Add a custom model ID to an existing provider.
new_model = "openai::gpt-3.5-turbo"
custom_model_ids = Config.shared().custom_models
existing_model = next((m for m in custom_model_ids if m == new_model), None)
if existing_model:
    # skip since this already exists
    return
custom_model_ids.append(new_model)
Config.shared().custom_models = custom_model_ids
```

## Taking Kiln RAG to production

When you're ready to deploy your RAG system, you can export your processed documents to any vector store supported by LlamaIndex. This allows you to use your Kiln-configured chunking and embedding settings in production.

### Load a LlamaIndex Vector Store

Kiln provides a `VectorStoreLoader` that yields your processed document chunks as LlamaIndex `TextNode` objects. These nodes contain the same metadata, chunking and embedding data as your Kiln Search Tool configuration.

```py
from kiln_ai.datamodel import Project
from kiln_ai.datamodel.rag import RagConfig
from kiln_ai.adapters.vector_store_loaders import VectorStoreLoader

# Load your project and RAG configuration
project = Project.load_from_file("path/to/your/project.kiln")
rag_config = RagConfig.from_id_and_parent_path("rag-config-id", project.path)

# Create the loader
loader = VectorStoreLoader(project=project, rag_config=rag_config)

# Export chunks to any LlamaIndex vector store
async for batch in loader.iter_llama_index_nodes(batch_size=10):
    # Insert into your chosen vector store
    # Examples: LanceDB, Pinecone, Chroma, Qdrant, etc.
    pass
```

**Supported Vector Stores:** LlamaIndex supports 20+ vector stores including LanceDB, Pinecone, Weaviate, Chroma, Qdrant, and more. See the [full list](https://developers.llamaindex.ai/python/framework/module_guides/storing/vector_stores/).

### Example: LanceDB Cloud

Internally Kiln uses LanceDB. By using LanceDB cloud you'll get the same indexing behaviour as in app.

Here's a complete example using LanceDB Cloud:

```py
from kiln_ai.datamodel import Project
from kiln_ai.datamodel.rag import RagConfig
from kiln_ai.datamodel.vector_store import VectorStoreConfig
from kiln_ai.adapters.vector_store_loaders import VectorStoreLoader
from kiln_ai.adapters.vector_store.lancedb_adapter import lancedb_construct_from_config

# Load configurations
project = Project.load_from_file("path/to/your/project.kiln")
rag_config = RagConfig.from_id_and_parent_path("rag-config-id", project.path)
vector_store_config = VectorStoreConfig.from_id_and_parent_path(
    rag_config.vector_store_config_id, project.path,
)

# Create LanceDB vector store
lancedb_store = lancedb_construct_from_config(
    vector_store_config=vector_store_config,
    uri="db://my-project",
    api_key="sk_...",
    region="us-east-1",
    table_name="my-documents",  # Created automatically
)

# Export and insert your documents
loader = VectorStoreLoader(project=project, rag_config=rag_config)
async for batch in loader.iter_llama_index_nodes(batch_size=100):
    await lancedb_store.async_add(batch)

print("Documents successfully exported to LanceDB!")
```

After export, query your data using [LlamaIndex](https://developers.llamaindex.ai/python/framework-api-reference/storage/vector_store/lancedb/) or the [LanceDB client](https://lancedb.github.io/lancedb/).

### Deploy RAG without LlamaIndex

While Kiln is designed for deploying to LlamaIndex, you don't need to use it. The `iter_llama_index_nodes` returns a `TextNode` object which includes all the data you need to build a RAG index in any stack: embedding, text, document name, chunk ID, etc.

## Connecting to Telemetry / MLOps (OpenTelemetry, Braintrust, etc)

You can connect the Kiln SDK to a wide range of MLOps, trace tracking, and telemetry platforms.

Kiln uses the LiteLLM SDK, which supports all major telemetry providers. See LiteLLM's documentation for how to set up each provider:

- [OpenTelemetry](https://docs.litellm.ai/docs/observability/opentelemetry_integration)
- [Braintrust](https://docs.litellm.ai/docs/observability/braintrust)
- [MLFlow](https://docs.litellm.ai/docs/observability/mlflow)
- [LangFuse](https://docs.litellm.ai/docs/observability/langfuse_otel_integration)
- Many more (see LiteLLM documentation)

## Full API Reference

The library can do a lot more than the examples we've shown here.

See the full API reference in the [docs](https://kiln-ai.github.io/Kiln/kiln_core_docs/index.html) under the `Submodules` section of the sidebar.

## 2. Official Technical Reference & Guides (Kiln-AI/docs)

---
icon: hand-wave
---

# Welcome to Kiln AI

Kiln AI is the easiest tool for:

* 🎛️ [**Fine Tuning**](docs/fine-tuning/fine-tuning-guide.md): Zero-code fine-tuning for Llama, GPT-4o, and more. Automatic serverless deployment of models.
* 📊 [**Evals**](docs/evals-and-specs/evaluations.md): Evaluate the quality of your models/tasks using state of the art evaluators.
* 📈 [**Optimizers**](docs/optimizers.md): Find the best model, prompt or fine-tune for your task. Improve quality and lower costs.
* 🔍 [**Docs & Search (RAG)**](docs/documents-and-search-rag.md): Add knowledge to your AI systems with Retrieval-Augmented Generation (RAG)
* 🤖 [**Agents**](docs/agents.md): Build agentic systems with multiple actors
* 🛠 [**Tools & MCP**](docs/tools-and-mcp/): Connect powerful tools to your Kiln tasks, or write your own in Python with [Code Tools](docs/tools-and-mcp/code-tools.md)
* 🧩 [**Skills**](docs/skills.md): Load more instructions, depending on the goal.
* 🪄 [**Synthetic Data Generation**](docs/synthetic-data-generation/): Generate training data with our interactive visual tooling.
* 🧠 [**Reasoning Models**](docs/fine-tuning/guide-train-a-reasoning-model.md): Train or distill your own custom reasoning models.
* 🤝 [**Team Collaboration**](docs/collaboration/): Git-based version control for your AI datasets. Intuitive UI makes it easy to collaborate with QA, PM, and subject matter experts on structured data (examples, prompts, ratings, feedback, issues, etc.).

### Jump right in



|  |  |  |  | Cover image |
| --- | --- | --- | --- | --- |
| **Quickstart** | Download our app, setup a task, and run AI models. |  | [quickstart.md](docs/quickstart.md) | [App3.png](.gitbook/assets/App3.png) |
| **Automatic Prompt Optimizer** | Find the best possible prompt for your task. |  | [automatic-prompt-optimizer.md](docs/prompts/automatic-prompt-optimizer.md) | [Prompts3.png](.gitbook/assets/Prompts3.png) |
| **Models and AI Providers** | Manage which models you can use in Kiln. |  | [models-and-ai-providers.md](docs/models-and-ai-providers.md) | [providers3.png](.gitbook/assets/providers3.png) |
| **Fine Tuning** | Our guide for fine tuning AI models |  | [fine-tuning-guide.md](docs/fine-tuning/fine-tuning-guide.md) | [tuning2.png](.gitbook/assets/tuning2.png) |
| **Evals** | Evaluate the quality of your models/tasks |  | [evals-and-specs](docs/evals-and-specs/) | [Eval (1).png](.gitbook/assets/Eval (1).png) |
| **Tools &#x26; MCP** | Connect tools to Kiln |  | [tools-and-mcp](docs/tools-and-mcp/) | [MCP.png](.gitbook/assets/MCP.png) |
| **Code Tools** | Write a Python function that runs as a tool |  | [code-tools.md](docs/tools-and-mcp/code-tools.md) | [tools2.png](.gitbook/assets/tools2.png) |
| **Search Tools / RAG** | Add documents and create search indexes |  | [documents-and-search-rag.md](docs/documents-and-search-rag.md) | [rag icon 2-2.png](.gitbook/assets/rag icon 2-2.png) |
| **Agents** | Build multi-action agentic systems |  | [agents.md](docs/agents.md) | [Agents-2.png](.gitbook/assets/Agents-2.png) |
| **Synthetic Data Generation** | Generate training data for models with AI |  | [synthetic-data-generation](docs/synthetic-data-generation/) | [synth.png](.gitbook/assets/synth.png) |
| **Skills** | Dynamically load prompts for the current goal. |  | [skills.md](docs/skills.md) | [skills.png](.gitbook/assets/skills.png) |
| **Python Library Setup** | Install and use our python library. |  | [python-library-quickstart.md](developers/python-library-quickstart.md) | [python3.png](.gitbook/assets/python3.png) |
| **Demo Project** | End to end demo video showing how to use Kiln |  | [end-to-end-project-demo.md](docs/end-to-end-project-demo.md) | [Video-2.png](.gitbook/assets/Video-2.png) |
| **Build a Reasoning Model** | Create your own reasoning model, like o3 or R1 |  | [guide-train-a-reasoning-model.md](docs/fine-tuning/guide-train-a-reasoning-model.md) | [distill.png](.gitbook/assets/distill.png) |