Raw OpenAI-Compatible Fetch
If you already have an OpenAI-compatible HTTP client or a custom fetch wrapper, @vel4ai/ai-sdk is not required. Use the URL and headers returned by prepared execution to call /chat/completions. This is a Vela-managed relay call, so the relay records completion / failure and usage when available.
Non-Streaming
Section titled “Non-Streaming”declare const prepared: import("@vel4ai/sdk").PreparedExecutionAllowed;declare const messages: Array<{ role: "user"; content: string }>;
export async function callRelay() { const response = await fetch(prepared.openAiCompatibleChatCompletionsUrl, { method: "POST", headers: prepared.openAiCompatibleRequestHeaders, body: JSON.stringify({ model: prepared.openAiCompatibleModel, messages, }), }); const body = (await response.json()) as { usage?: unknown };
return body;}Streaming
Section titled “Streaming”For streaming, return the relay response directly. The Vela-managed relay records the execution result asynchronously.
declare const prepared: import("@vel4ai/sdk").PreparedExecutionAllowed;
export async function proxyRelayStream(messages: unknown[]) { const response = await fetch(prepared.openAiCompatibleChatCompletionsUrl, { method: "POST", headers: prepared.openAiCompatibleRequestHeaders, body: JSON.stringify({ model: prepared.openAiCompatibleModel, messages, stream: true, }), });
return response;}