mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-29 01:39:24 +08:00
fix(core): Support bare models for custom AI Assistant endpoints (#34016)
This commit is contained in:
@@ -82,6 +82,19 @@ const LANGUAGE_PROVIDERS: ProviderRegistry = {
|
||||
return creds.baseURL ? provider.chat(model) : provider(model);
|
||||
},
|
||||
},
|
||||
custom: {
|
||||
build: (creds, model, fetch) => {
|
||||
const { createOpenAICompatible } =
|
||||
require('@ai-sdk/openai-compatible') as typeof import('@ai-sdk/openai-compatible');
|
||||
return createOpenAICompatible({
|
||||
name: 'custom',
|
||||
baseURL: creds.baseURL,
|
||||
apiKey: creds.apiKey,
|
||||
headers: creds.headers,
|
||||
fetch,
|
||||
})(model);
|
||||
},
|
||||
},
|
||||
anthropic: {
|
||||
build: (creds, model, fetch) => {
|
||||
const { createAnthropic } =
|
||||
|
||||
@@ -12,6 +12,9 @@ const apiKeyCreds = z.object({
|
||||
*/
|
||||
export const PROVIDER_CREDENTIAL_SCHEMAS = {
|
||||
openai: apiKeyCreds,
|
||||
custom: apiKeyCreds.extend({
|
||||
baseURL: z.string().min(1, 'baseURL is required'),
|
||||
}),
|
||||
anthropic: apiKeyCreds,
|
||||
google: apiKeyCreds,
|
||||
xai: apiKeyCreds,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Config, Env } from '../decorators';
|
||||
|
||||
@Config
|
||||
export class InstanceAiConfig {
|
||||
/** LLM model in provider/model format (e.g. "anthropic/claude-opus-4-8"). */
|
||||
/** LLM model in provider/model format, or a bare model name for a custom endpoint. */
|
||||
@Env('N8N_INSTANCE_AI_MODEL')
|
||||
model: string = 'anthropic/claude-opus-4-8';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ All Instance AI configuration is done via environment variables.
|
||||
|
||||
| Variable | Type | Default | Description |
|
||||
|----------|------|---------|-------------|
|
||||
| `N8N_INSTANCE_AI_MODEL` | string | `anthropic/claude-opus-4-8` | LLM model in `provider/model` format. Must be set for the module to enable. |
|
||||
| `N8N_INSTANCE_AI_MODEL` | string | `anthropic/claude-opus-4-8` | LLM model in `provider/model` format for built-in providers, or a bare model name when `N8N_INSTANCE_AI_MODEL_URL` is set. Must be set for the module to enable. |
|
||||
| `N8N_INSTANCE_AI_MODEL_URL` | string | `''` | Base URL for an OpenAI-compatible endpoint (e.g. `http://localhost:1234/v1` for LM Studio). When set, model requests go to this URL instead of the built-in provider. |
|
||||
| `N8N_INSTANCE_AI_MODEL_API_KEY` | string | `''` | API key for the custom model endpoint. Optional — some local servers don't require one. |
|
||||
| `N8N_INSTANCE_AI_MCP_SERVERS` | string | `''` | Comma-separated MCP server configs. Format: `name=url,name=url` |
|
||||
@@ -208,6 +208,7 @@ N8N_INSTANCE_AI_GATEWAY_API_KEY=my-secret-key
|
||||
# User runs: npx @n8n/computer-use
|
||||
|
||||
# With custom OpenAI-compatible endpoint (e.g. LM Studio, Ollama)
|
||||
N8N_INSTANCE_AI_MODEL=your-tool-capable-model
|
||||
N8N_INSTANCE_AI_MODEL_URL=http://localhost:1234/v1
|
||||
|
||||
# Output filtering — secrets + email only, with a custom placeholder
|
||||
|
||||
Reference in New Issue
Block a user