コンテンツにスキップ

Relay Target

allow された prepared execution には、OpenAI Compatible clientでそのまま使えるrelay targetが含まれます。providerがOpenRouter、OpenAI、Anthropic、OpenAI Compatible、Local Connectorのどれであっても、アプリはこの抽象を優先します。

field用途
openAiCompatibleModel実際に呼ぶmodel id
openAiCompatibleClientOptions{ apiKey, baseURL }。OpenAI compatible clientへ渡す
openAiCompatibleChatCompletionsUrlraw fetch用の /chat/completions URL
openAiCompatibleRequestHeadersraw fetch用のAuthorization / content-type headers
declare const prepared: import("@vel4ai/sdk").PreparedExecutionAllowed;
declare function createOpenAIClient(input: {
apiKey: string;
baseURL: string;
}): { chat: { completions: { create(input: unknown): Promise<unknown> } } };
export async function callViaClient(messages: unknown[]) {
const client = createOpenAIClient(prepared.openAiCompatibleClientOptions);
return client.chat.completions.create({
model: prepared.openAiCompatibleModel,
messages,
});
}
declare const prepared: import("@vel4ai/sdk").PreparedExecutionAllowed;
declare const messages: Array<{ role: "user"; content: string }>;
export async function callViaRawFetch() {
const response = await fetch(prepared.openAiCompatibleChatCompletionsUrl, {
method: "POST",
headers: prepared.openAiCompatibleRequestHeaders,
body: JSON.stringify({
model: prepared.openAiCompatibleModel,
messages,
}),
});
return response.json() as Promise<unknown>;
}

provider差分をアプリに漏らさない

Section titled “provider差分をアプリに漏らさない”

Anthropic backend もVela側でOpenAI Compatible shapeへ寄せます。アプリが直接Anthropic SDKへ分岐すると、委任・監査・失効の境界が崩れるため、prepared executionのrelay targetを優先してください。