Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ FIRECRAWL_KEY="your_firecrawl_key"
OPENAI_KEY="your_openai_key"
```

To use local LLM, comment out `OPENAI_KEY` and instead uncomment `OPENAI_ENDPOINT` and `OPENAI_MODEL`:
To use a local LLM, uncomment `OPENAI_ENDPOINT` and `CUSTOM_MODEL` (you do not need to set `OPENAI_KEY` when using a local endpoint):

- Set `OPENAI_ENDPOINT` to the address of your local server (eg."http://localhost:1234/v1")
- Set `OPENAI_MODEL` to the name of the model loaded in your local server.
- Set `OPENAI_ENDPOINT` to the address of your local server (eg."http://localhost:11434/v1")
- Set `CUSTOM_MODEL` to the name of the model loaded in your local server.

### Docker

Expand Down
15 changes: 9 additions & 6 deletions src/ai/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import { getEncoding } from 'js-tiktoken';
import { RecursiveCharacterTextSplitter } from './text-splitter';

// Providers
const openai = process.env.OPENAI_KEY
? createOpenAI({
apiKey: process.env.OPENAI_KEY,
baseURL: process.env.OPENAI_ENDPOINT || 'https://api.openai.com/v1',
})
: undefined;
// Create openai client when OPENAI_KEY is set, or when CUSTOM_MODEL is configured
// (local/OpenAI-compatible endpoints don't require a real API key)
const openai =
process.env.OPENAI_KEY || process.env.CUSTOM_MODEL
? createOpenAI({
apiKey: process.env.OPENAI_KEY || 'placeholder',
baseURL: process.env.OPENAI_ENDPOINT || 'https://api.openai.com/v1',
})
: undefined;

const fireworks = process.env.FIREWORKS_KEY
? createFireworks({
Expand Down