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
3 changes: 3 additions & 0 deletions apps/web/client/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ GITHUB_APP_PRIVATE_KEY="<Your app's private key hash>"

# ------------- Optional: Alternative LLM providers -------------

# MiniMax
MINIMAX_API_KEY="<Your api key from https://platform.minimaxi.com/user-center/basic-information/interface-key>"

# Anthropic
ANTHROPIC_API_KEY="<Your api key from https://console.anthropic.com/settings/keys>"

Expand Down
2 changes: 2 additions & 0 deletions apps/web/client/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const env = createEnv({
ANTHROPIC_API_KEY: z.string().optional(),
GOOGLE_AI_STUDIO_API_KEY: z.string().optional(),
OPENAI_API_KEY: z.string().optional(),
MINIMAX_API_KEY: z.string().optional(),

// n8n
N8N_WEBHOOK_URL: z.string().optional(),
Expand Down Expand Up @@ -130,6 +131,7 @@ export const env = createEnv({
GOOGLE_AI_STUDIO_API_KEY: process.env.GOOGLE_AI_STUDIO_API_KEY,
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
MINIMAX_API_KEY: process.env.MINIMAX_API_KEY,

// n8n
N8N_WEBHOOK_URL: process.env.N8N_WEBHOOK_URL,
Expand Down
6 changes: 5 additions & 1 deletion docs/content/docs/self-hosting/external-services.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ For assistance with self-hosting these services, please contact us at [founders@

### 3. AI Providers
To configure custom AI providers:
1. Update the providers in [`packages/ai/src/chat/providers.ts`](https://github.com/onlook-dev/onlook/blob/main/packages/ai/src/chat/providers.ts). We already support Anthropic and OpenRouter as examples. You can follow the same format to add a new provider.
1. Update the providers in [`packages/ai/src/chat/providers.ts`](https://github.com/onlook-dev/onlook/blob/main/packages/ai/src/chat/providers.ts). We already support OpenRouter, MiniMax, and Anthropic as examples. You can follow the same format to add a new provider.
2. Update the usages by searching for [`initModel`](https://github.com/search?q=repo%3Aonlook-dev%2Fonlook+%22await+initModel%22&type=code)
3. Update your API keys in the `apps/web/client/.env` file to the provider's expected API keys.

Built-in providers:
- **OpenRouter** (default) — access to multiple models via a single API key
- **[MiniMax](https://platform.minimaxi.com)** — MiniMax-M3 models with up to 512K context window (default)

Note: We support any provider from the [AI SDK providers](https://ai-sdk.dev/providers/ai-sdk-providers). You can add a custom provider by following these AI SDK provider guides: [OpenAI compatible](https://ai-sdk.dev/providers/openai-compatible-providers/custom-providers) and [Community](https://ai-sdk.dev/providers/community-providers/custom-providers).
1 change: 1 addition & 0 deletions packages/ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"typescript": "^5.5.4"
},
"dependencies": {
"@ai-sdk/openai-compatible": "^1.0.34",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check available versions of `@ai-sdk/openai-compatible`
curl -s https://registry.npmjs.org/@ai-sdk/openai-compatible | jq '.versions | keys | .[-5:]'

# Check peer dependencies
curl -s https://registry.npmjs.org/@ai-sdk/openai-compatible/1.0.34 | jq '.peerDependencies'

Repository: onlook-dev/onlook

Length of output: 173


Update @ai-sdk/openai-compatible to a valid version.

Version 1.0.34 does not exist in the npm registry. The latest stable versions are 2.0.8 and 2.0.9. Update the dependency to one of these versions or the latest available version that meets the project requirements.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ai/package.json` at line 36, The package.json entry for the
dependency "@ai-sdk/openai-compatible" uses a nonexistent version ("^1.0.34");
update that dependency in packages/ai/package.json by replacing the version
string with a valid released version such as "^2.0.9" (or "^2.0.8" if preferred)
so the dependency resolves correctly during installs.

"@mendable/firecrawl-js": "^1.29.1",
"@openrouter/ai-sdk-provider": "^1.2.0",
"ai": "5.0.60",
Expand Down
17 changes: 17 additions & 0 deletions packages/ai/src/chat/providers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
LLMProvider,
MINIMAX_MODELS,
MODEL_MAX_TOKENS,
OPENROUTER_MODELS,
type InitialModelPayload,
type ModelConfig
} from '@onlook/models';
import { assertNever } from '@onlook/utility';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { createOpenRouter } from '@openrouter/ai-sdk-provider';
import type { LanguageModel } from 'ai';

Expand Down Expand Up @@ -33,6 +35,9 @@ export function initModel({
? { ...providerOptions, anthropic: { cacheControl: { type: 'ephemeral' } } }
: providerOptions;
break;
case LLMProvider.MINIMAX:
model = getMinimaxProvider(requestedModel);
break;
default:
assertNever(requestedProvider);
}
Expand All @@ -52,3 +57,15 @@ function getOpenRouterProvider(model: OPENROUTER_MODELS): LanguageModel {
const openrouter = createOpenRouter({ apiKey: process.env.OPENROUTER_API_KEY });
return openrouter(model);
}

function getMinimaxProvider(model: MINIMAX_MODELS): LanguageModel {
if (!process.env.MINIMAX_API_KEY) {
throw new Error('MINIMAX_API_KEY must be set');
}
const minimax = createOpenAICompatible({
name: 'minimax',
baseURL: 'https://api.minimax.io/v1',
apiKey: process.env.MINIMAX_API_KEY,
});
return minimax(model);
}
11 changes: 11 additions & 0 deletions packages/models/src/llm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { LanguageModel } from 'ai';

export enum LLMProvider {
OPENROUTER = 'openrouter',
MINIMAX = 'minimax',
}

export enum OPENROUTER_MODELS {
Expand All @@ -13,8 +14,15 @@ export enum OPENROUTER_MODELS {
OPEN_AI_GPT_5_NANO = 'openai/gpt-5-nano',
}

export enum MINIMAX_MODELS {
MINIMAX_M3 = 'MiniMax-M3',
MINIMAX_M2_7 = 'MiniMax-M2.7',
MINIMAX_M2_7_HIGHSPEED = 'MiniMax-M2.7-highspeed',
}

interface ModelMapping {
[LLMProvider.OPENROUTER]: OPENROUTER_MODELS;
[LLMProvider.MINIMAX]: MINIMAX_MODELS;
}

export type InitialModelPayload = {
Expand All @@ -37,4 +45,7 @@ export const MODEL_MAX_TOKENS = {
[OPENROUTER_MODELS.OPEN_AI_GPT_5_NANO]: 400000,
[OPENROUTER_MODELS.OPEN_AI_GPT_5_MINI]: 400000,
[OPENROUTER_MODELS.OPEN_AI_GPT_5]: 400000,
[MINIMAX_MODELS.MINIMAX_M3]: 512000,
[MINIMAX_MODELS.MINIMAX_M2_7]: 204000,
[MINIMAX_MODELS.MINIMAX_M2_7_HIGHSPEED]: 204000,
Comment on lines +48 to +50

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What are the maximum context window sizes (token limits) for MiniMax M3, M2.7, and M2.7-highspeed models?

💡 Result:

The maximum context window sizes (token limits) for the specified MiniMax models are as follows: MiniMax M3: Supports a context window of 1,000,000 tokens [1][2][3]. MiniMax M2.7: Supports a context window of 204,800 tokens [2][4][5]. MiniMax M2.7-highspeed: Supports a context window of 204,800 tokens [2][6][7]. These limits reflect the official specifications provided in MiniMax's documentation and related technical resources [2][8][9].

Citations:


🌐 Web query:

What does the official MiniMax documentation state for the maximum context window size (token limit) of the MiniMax text generation model M3?

💡 Result:

According to the official MiniMax documentation, the MiniMax M3 text generation model supports a context window of 1,000,000 tokens [1][2]. The model leverages a proprietary architecture called MiniMax Sparse Attention (MSA) to achieve this capacity [1][3]. Some documentation also specifies that the model maintains a guaranteed minimum of 512,000 tokens within this context window [1][4]. Additionally, the model is noted to support a maximum output of 1,000,000 tokens per request [5][6].

Citations:


🌐 Web query:

What does the official MiniMax documentation state for the maximum context window size (token limit) of the MiniMax text generation model M2.7?

💡 Result:

According to the official MiniMax API documentation, the MiniMax M2.7 text generation model has a maximum context window size of 204,800 tokens [1][2][3]. This limit applies to the total number of input and output tokens combined [1]. Authoritative sources, including the MiniMax platform documentation and technical integrations, consistently cite this 204,800-token (often referred to as 200K) capacity for the M2.7 series [4][5][1][2]. While some local deployment or alternative environment documentation may reference specific usage constraints or rounded figures [6][7], the official API specifications maintain 204,800 as the standard context limit [1][3].

Citations:


🌐 Web query:

What does the official MiniMax documentation state for the maximum context window size (token limit) of the MiniMax text generation model M2.7-highspeed?

💡 Result:

According to the official MiniMax API documentation, the MiniMax text generation model M2.7-highspeed has a context window size of 204,800 tokens [1][2][3]. This maximum token count refers to the combined total of both input and output tokens [2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant portion of the file around the snippet
sed -n '1,140p' packages/models/src/llm/index.ts | nl -ba | sed -n '35,90p'

# Find the constant identifier(s) around those lines
rg -n "MINIMAX_MODELS|MAX_TOKENS|token" packages/models/src/llm/index.ts

# Show where MAX_TOKENS values are used (across repo) to interpret semantics
# (Limit search to minimax model usage)
rg -n "MINIMAX_MODELS.*M3|MINIMAX_M2_7|MINIMAX_M2_7_HIGHSPEED" -S packages/models/src/llm

Repository: onlook-dev/onlook

Length of output: 104


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show relevant section with line numbers (nl not available)
cat -n packages/models/src/llm/index.ts | sed -n '35,90p'

# Locate related constants / token limit definitions
rg -n "MINIMAX_MODELS|MAX_TOKENS|token" packages/models/src/llm/index.ts

# Find where the specific MINIMAX_MODELS token values are used
rg -n "MINIMAX_MODELS\.MINIMAX_M3|MINIMAX_MODELS\.MINIMAX_M2_7|MINIMAX_MODELS\.MINIMAX_M2_7_HIGHSPEED" -S packages/models/src/llm

# Also search across repo in case values are referenced elsewhere
rg -n "MINIMAX_MODELS\.MINIMAX_M3|MINIMAX_MODELS\.MINIMAX_M2_7|MINIMAX_MODELS\.MINIMAX_M2_7_HIGHSPEED" -S .

Repository: onlook-dev/onlook

Length of output: 1540


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find usages of MODEL_MAX_TOKENS
rg -n "MODEL_MAX_TOKENS" -S .

# Find how maxOutputTokens / token limits are used around providers
rg -n "maxOutputTokens" -S packages/models/src/llm packages -S

# Specifically see where token limits are enforced (truncate/chunk)
rg -n "truncate|truncat|token( |-|_)limit|max.*token|max_tokens|maxTokens|context window" -S packages/models/src/llm packages/models/src

Repository: onlook-dev/onlook

Length of output: 949


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- packages/ai/src/chat/providers.ts ----"
cat -n packages/ai/src/chat/providers.ts | sed -n '1,140p'

echo
echo "---- chat-context.tsx ----"
cat -n apps/web/client/src/app/project/[id]/_components/right-panel/chat-tab/chat-input/chat-context.tsx | sed -n '1,140p'

# Look for minimax request payload fields
echo
echo "---- Search for minimax request max_tokens fields ----"
rg -n "minimax|MINIMAX|max_tokens|maxTokens|maxOutputTokens|context|tokens" -S packages/ai/src/chat packages/ai/src

Repository: onlook-dev/onlook

Length of output: 18637


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "maxOutputTokens" -S packages/ai/src

# Show likely call sites: files that call initModel or consume ModelConfig
rg -n "initModel\\(" -S packages/ai/src

# Follow MODEL_MAX_TOKENS usage further
rg -n "MODEL_MAX_TOKENS\\[" -S packages/ai/src packages -S

Repository: onlook-dev/onlook

Length of output: 701


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- packages/ai/src/agents/root.ts ----"
cat -n packages/ai/src/agents/root.ts | sed -n '1,180p'

echo
echo "---- usages of maxOutputTokens in packages/ai/src ----"
rg -n "maxOutputTokens" -S packages/ai/src

echo
echo "---- search for maxTokens / max_tokens in packages/ai/src ----"
rg -n "maxTokens|max_tokens|max_output_tokens" -S packages/ai/src

Repository: onlook-dev/onlook

Length of output: 5197


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "maxOutputTokens" -S .

rg -n "maxTokens\\b|max_tokens\\b|maxOutput\\b" -S packages apps

Repository: onlook-dev/onlook

Length of output: 1960


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- chat/conversation.ts ----"
cat -n apps/web/client/src/server/api/routers/chat/conversation.ts | sed -n '1,200p'

echo
echo "---- chat/suggestion.ts ----"
cat -n apps/web/client/src/server/api/routers/chat/suggestion.ts | sed -n '1,120p'

echo
echo "---- project.ts around line ~329 ----"
cat -n apps/web/client/src/server/api/routers/project/project.ts | sed -n '280,380p'

echo
echo "---- search packages/ai for maxOutputTokens usage ----"
rg -n "maxOutputTokens" -S packages/ai/src

Repository: onlook-dev/onlook

Length of output: 13385


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "LLMProvider\\.MINIMAX|MINIMAX_MODELS\\." -S .

Repository: onlook-dev/onlook

Length of output: 466


Align MiniMax MODEL_MAX_TOKENS values with the official context-window limits.

  • MiniMax M3: official max context window is 1,000,000 tokens (with a guaranteed minimum of 512,000), but code sets 512,000.
  • MiniMax M2.7 / M2.7-highspeed: official max context window is 204,800 tokens, but code sets 204,000.
  • MODEL_MAX_TOKENS is used as maxOutputTokens (packages/ai/src/chat/providers.ts), so these underestimates will reduce the usable budget when MiniMax is actually selected; either update to the official maxima or rename/document these constants as “safe/guaranteed minimum” rather than max.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/models/src/llm/index.ts` around lines 48 - 50, The MINI MAX model
token limits in the MODEL_MAX_TOKENS mapping are set below the official
context-window limits for MINIMAX_M3 and MINIMAX_M2_7/M2_7_HIGHSPEED; update the
entries keyed by MINIMAX_MODELS.MINIMAX_M3, MINIMAX_MODELS.MINIMAX_M2_7, and
MINIMAX_MODELS.MINIMAX_M2_7_HIGHSPEED to the official maxima (set M3 to 1000000
with note that 512000 is guaranteed minimum, and set M2.7 / M2.7-highspeed to
204800) so that consumers using MODEL_MAX_TOKENS (e.g., maxOutputTokens in
packages/ai/src/chat/providers.ts) get the correct budget, or alternatively
rename/document the mapping to indicate these are "guaranteed minimum" values
rather than maxima if you intend to keep the lower numbers.

} as const;