CompatibleModelConfig
SUPPORT · interface · Type contract
Configuration of one OpenAI-compatible endpoint.
Import
ts
import type { CompatibleModelConfig } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').CompatibleModelConfig} CompatibleModelConfig */Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/support, @jangts/agent-core/support/model.
Definition
ts
interface CompatibleModelConfigField structure
| Field | Type | Required | Description |
|---|---|---|---|
baseUrl | string | Required | Endpoint base URL, for example the chat-completions root. |
apiKey | string | Required | Credential sent as a bearer token; must be non-empty at request time. |
model | string | Required | Model name sent with the request. |
maxOutputTokens | number | undefined | Optional | Optional provider ceiling; otherwise use the call's limit or the Core default. |
requestBody | (Readonly<Record<string, unknown>> & { readonly model?: never; readonly messages?: never; readonly stream?: never; readonly max_tokens?: never; readonly max_completion_tokens?: never; readonly toJSON?: never; }) | undefined | Optional | Provider extensions. Identity, input, streaming and budget stay in the adapter. |
temperature | number | undefined | Optional | Sampling temperature forwarded to the provider. |
reasoning | ProviderReasoningStrategy | undefined | Optional | Generated reasoning fields are overridden by explicit requestBody fields. |
Examples
- Compatible Provider and custom Providers: Support owns the common Chat Completions HTTP/SSE lifecycle; an App can substitute its own ChatProvider.
Connect a common protocol with real server-side configuration
Beginner · Node.js
Running this example requires connection configuration for an available model service.
ts
import { ModelRunner, Support } from '@jangts/agent-core';
const provider = new Support.CompatibleModelProvider({ config: {
baseUrl: process.env.MODEL_BASE_URL!, apiKey: process.env.MODEL_API_KEY!, model: process.env.MODEL_NAME!,
} });
const runner = new ModelRunner({ provider });
console.log((await runner.invoke('你好')).value);js
import { ModelRunner, Support } from '@jangts/agent-core';
const provider = new Support.CompatibleModelProvider({ config: {
baseUrl: process.env.MODEL_BASE_URL, apiKey: process.env.MODEL_API_KEY, model: process.env.MODEL_NAME,
} });
const runner = new ModelRunner({ provider });
console.log((await runner.invoke('你好')).value);Declared fields and wire mapping for a direct tool thread
Configuration · Node.js
This only demonstrates message conversion, with no network request or tool execution. Raw tool_calls, tool_call_id, and host-attached data are not forwarded.
ts
import { Support } from '@jangts/agent-core';
const messages: Support.ProviderMessage[] = [
{ role: 'user', content: '查询资料' },
{ role: 'assistant', content: '', toolCalls: [
{ id: 'call-1', name: 'lookup', arguments: '{"query":"资料"}' },
] },
{ role: 'tool', content: '{"found":true}', toolCallId: 'call-1' },
];
console.log(Support.chatCompletionMessages(messages));js
import { Support } from '@jangts/agent-core';
const messages = [
{ role: 'user', content: '查询资料' },
{ role: 'assistant', content: '', toolCalls: [
{ id: 'call-1', name: 'lookup', arguments: '{"query":"资料"}' },
] },
{ role: 'tool', content: '{"found":true}', toolCallId: 'call-1' },
];
console.log(Support.chatCompletionMessages(messages));