Parameters
- params: {
targetProvider: TargetProviderSDK;
toolCall: {
function: { arguments: string; name: string } & {
[k: string]: unknown;
};
id: string;
type: "function";
};
}toolCall: {
function: { arguments: string; name: string } & { [k: string]: unknown };
id: string;
type: "function";
}
Returns TypeOf<
{
ANTHROPIC: SDKConverters<
ZodEffects<
ZodDiscriminatedUnion<
"role",
[
ZodObject<
{
content: ...;
name: ...;
role: ...;
tool_call_id: ...;
tool_calls: ...;
},
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
ZodObject<
{ content: ...; role: ...; tool_call_id: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
ZodObject<
{ content: ...; name: ...; role: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
],
>,
objectOutputType<
{ content: ZodUnion<[(...), (...)]>; role: ZodEnum<[(...), (...)]> },
ZodTypeAny,
"passthrough",
>,
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodOptional<(...)>;
tool_calls: ZodOptional<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodString;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodNullable<(...)>;
name: ZodString;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodEffects<
ZodDiscriminatedUnion<
"type",
[
ZodObject<
{ text: ...; type: ... },
"strip",
ZodTypeAny,
{ text: ...; type: ... },
{ text: ...; type: ... },
>,
ZodObject<
{ image_url: ...; type: ... },
"strip",
ZodTypeAny,
{ image_url: ...; type: ... },
{ image_url: ...; type: ... },
>,
],
>,
| null
| { source?: undefined; text: string; type: "text" }
| {
source: {
data: string;
media_type: (...) | (...) | (...) | (...);
type: "base64";
};
text?: undefined;
type: "image";
},
| { text: string; type: "text" }
| { image_url: { url: string }; type: "image_url" },
>,
ZodEffects<
ZodUnion<
[
ZodLiteral<"auto">,
ZodLiteral<"none">,
ZodLiteral<"required">,
ZodObject<
{ function: ...; type: ... },
"strip",
ZodTypeAny,
{ function: ...; type: ... },
{ function: ...; type: ... },
>,
],
>,
{ name: string; type: "tool" } | { type: "auto" } | { type: "any" },
| "none"
| "auto"
| "required"
| { function: { name: string }; type: "function" },
>,
ZodEffects<
ZodObject<
{
function: ZodObject<
{ arguments: ...; name: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
id: ZodString;
type: ZodEffects<ZodOptional<(...)>, "function", (...) | (...)>;
},
"strip",
ZodTypeAny,
{
function: { arguments: ...; name: ... } & { [k: ...]: ... };
id: string;
type: "function";
},
{
function: { arguments: ...; name: ... } & { [k: ...]: ... };
id: string;
type?: "function";
},
>,
{ id: string; input: JSONLiteral; name: string; type: "tool_use" },
{
function: { arguments: string; name: string } & {
[k: string]: unknown;
};
id: string;
type?: "function";
},
>,
ZodEffects<
ZodObject<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{
function: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>,
objectInputType<
{
function: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>,
>,
{
description: string;
input_schema: {
additionalProperties?: (...)
| (...)
| (...);
properties: Record<(...), (...)>;
required?: (...) | (...);
type: "object";
} & { [k: string]: unknown };
name: string;
},
objectInputType<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodTypeAny,
>;
AZURE_OPENAI: SDKConverters<
ZodDiscriminatedUnion<
"role",
[
ZodObject<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodOptional<(...)>;
tool_calls: ZodOptional<(...)>;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{
content: ...;
name: ...;
role: ...;
tool_call_id: ...;
tool_calls: ...;
},
ZodTypeAny,
"passthrough",
>,
objectInputType<
{
content: ...;
name: ...;
role: ...;
tool_call_id: ...;
tool_calls: ...;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodObject<
{
content: ZodUnion<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodString;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{ content: ...; role: ...; tool_call_id: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ content: ...; role: ...; tool_call_id: ... },
ZodTypeAny,
"passthrough",
>,
>,
ZodObject<
{
content: ZodNullable<(...)>;
name: ZodString;
role: ZodLiteral<(...)>;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{ content: ...; name: ...; role: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ content: ...; name: ...; role: ... },
ZodTypeAny,
"passthrough",
>,
>,
],
>,
ZodDiscriminatedUnion<
"type",
[
ZodObject<
{ text: ZodString; type: ZodLiteral<(...)> },
"strip",
ZodTypeAny,
{ text: string; type: "text" },
{ text: string; type: "text" },
>,
ZodObject<
{
image_url: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
"strip",
ZodTypeAny,
{ image_url: { url: ... }; type: "image_url" },
{ image_url: { url: ... }; type: "image_url" },
>,
],
>,
ZodUnion<
[
ZodLiteral<"auto">,
ZodLiteral<"none">,
ZodLiteral<"required">,
ZodObject<
{
function: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
"strip",
ZodTypeAny,
{ function: { name: ... }; type: "function" },
{ function: { name: ... }; type: "function" },
>,
],
>,
ZodObject<
{
function: ZodObject<
{ arguments: ZodString; name: ZodString },
"passthrough",
ZodTypeAny,
objectOutputType<
{ arguments: ...; name: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ arguments: ...; name: ... },
ZodTypeAny,
"passthrough",
>,
>;
id: ZodString;
type: ZodEffects<
ZodOptional<ZodLiteral<(...)>>,
"function",
undefined | "function",
>;
},
"strip",
ZodTypeAny,
{
function: { arguments: string; name: string } & {
[k: string]: unknown;
};
id: string;
type: "function";
},
{
function: { arguments: string; name: string } & {
[k: string]: unknown;
};
id: string;
type?: "function";
},
>,
ZodObject<
{
function: ZodObject<
{
description: ZodOptional<(...)>;
name: ZodString;
parameters: ZodObject<(...), (...), (...), (...), (...)>;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{ description: ...; name: ...; parameters: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ description: ...; name: ...; parameters: ... },
ZodTypeAny,
"passthrough",
>,
>;
type: ZodLiteral<"function">;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
ZodTypeAny,
"passthrough",
>,
objectInputType<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodObject<
{
json_schema: ZodObject<
{
description: ZodOptional<(...)>;
name: ZodString;
schema: ZodObject<(...), (...), (...), (...), (...)>;
},
"strip",
ZodTypeAny,
{ description?: (...)
| (...); name: string; schema: (...) & (...) },
{ description?: (...) | (...); name: string; schema: (...) & (...) },
>;
type: ZodLiteral<"json_schema">;
},
"strip",
ZodTypeAny,
{
json_schema: {
description?: string;
name: string;
schema: {
additionalProperties?: ...;
properties: ...;
required?: ...;
type: ...;
} & { [k: ...]: ... };
};
type: "json_schema";
},
{
json_schema: {
description?: string;
name: string;
schema: {
additionalProperties?: ...;
properties: ...;
required?: ...;
type: ...;
} & { [k: ...]: ... };
};
type: "json_schema";
},
>,
>;
OPENAI: SDKConverters<
ZodDiscriminatedUnion<
"role",
[
ZodObject<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodOptional<(...)>;
tool_calls: ZodOptional<(...)>;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{
content: ...;
name: ...;
role: ...;
tool_call_id: ...;
tool_calls: ...;
},
ZodTypeAny,
"passthrough",
>,
objectInputType<
{
content: ...;
name: ...;
role: ...;
tool_call_id: ...;
tool_calls: ...;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodObject<
{
content: ZodUnion<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodString;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{ content: ...; role: ...; tool_call_id: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ content: ...; role: ...; tool_call_id: ... },
ZodTypeAny,
"passthrough",
>,
>,
ZodObject<
{
content: ZodNullable<(...)>;
name: ZodString;
role: ZodLiteral<(...)>;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{ content: ...; name: ...; role: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ content: ...; name: ...; role: ... },
ZodTypeAny,
"passthrough",
>,
>,
],
>,
ZodDiscriminatedUnion<
"type",
[
ZodObject<
{ text: ZodString; type: ZodLiteral<(...)> },
"strip",
ZodTypeAny,
{ text: string; type: "text" },
{ text: string; type: "text" },
>,
ZodObject<
{
image_url: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
"strip",
ZodTypeAny,
{ image_url: { url: ... }; type: "image_url" },
{ image_url: { url: ... }; type: "image_url" },
>,
],
>,
ZodUnion<
[
ZodLiteral<"auto">,
ZodLiteral<"none">,
ZodLiteral<"required">,
ZodObject<
{
function: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
"strip",
ZodTypeAny,
{ function: { name: ... }; type: "function" },
{ function: { name: ... }; type: "function" },
>,
],
>,
ZodObject<
{
function: ZodObject<
{ arguments: ZodString; name: ZodString },
"passthrough",
ZodTypeAny,
objectOutputType<
{ arguments: ...; name: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ arguments: ...; name: ... },
ZodTypeAny,
"passthrough",
>,
>;
id: ZodString;
type: ZodEffects<
ZodOptional<ZodLiteral<(...)>>,
"function",
undefined | "function",
>;
},
"strip",
ZodTypeAny,
{
function: { arguments: string; name: string } & {
[k: string]: unknown;
};
id: string;
type: "function";
},
{
function: { arguments: string; name: string } & {
[k: string]: unknown;
};
id: string;
type?: "function";
},
>,
ZodObject<
{
function: ZodObject<
{
description: ZodOptional<(...)>;
name: ZodString;
parameters: ZodObject<(...), (...), (...), (...), (...)>;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{ description: ...; name: ...; parameters: ... },
ZodTypeAny,
"passthrough",
>,
objectInputType<
{ description: ...; name: ...; parameters: ... },
ZodTypeAny,
"passthrough",
>,
>;
type: ZodLiteral<"function">;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
ZodTypeAny,
"passthrough",
>,
objectInputType<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodObject<
{
json_schema: ZodObject<
{
description: ZodOptional<(...)>;
name: ZodString;
schema: ZodObject<(...), (...), (...), (...), (...)>;
},
"strip",
ZodTypeAny,
{ description?: (...)
| (...); name: string; schema: (...) & (...) },
{ description?: (...) | (...); name: string; schema: (...) & (...) },
>;
type: ZodLiteral<"json_schema">;
},
"strip",
ZodTypeAny,
{
json_schema: {
description?: string;
name: string;
schema: {
additionalProperties?: ...;
properties: ...;
required?: ...;
type: ...;
} & { [k: ...]: ... };
};
type: "json_schema";
},
{
json_schema: {
description?: string;
name: string;
schema: {
additionalProperties?: ...;
properties: ...;
required?: ...;
type: ...;
} & { [k: ...]: ... };
};
type: "json_schema";
},
>,
>;
PHOENIX: SDKConverters<
ZodEffects<
ZodDiscriminatedUnion<
"role",
[
ZodObject<
{
content: ...;
name: ...;
role: ...;
tool_call_id: ...;
tool_calls: ...;
},
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
ZodObject<
{ content: ...; role: ...; tool_call_id: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
ZodObject<
{ content: ...; name: ...; role: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
],
>,
{
content: string | ((...) | (...) | (...))[];
role:
| "user"
| "assistant"
| "model"
| "ai"
| "tool"
| "system"
| "developer";
},
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodOptional<(...)>;
tool_calls: ZodOptional<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodString;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodNullable<(...)>;
name: ZodString;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodUnknown,
ZodUnknown,
ZodUnknown,
ZodUnknown,
ZodUnknown,
>;
VERCEL_AI: SDKConverters<
ZodEffects<
ZodDiscriminatedUnion<
"role",
[
ZodObject<
{
content: ...;
name: ...;
role: ...;
tool_call_id: ...;
tool_calls: ...;
},
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
ZodObject<
{ content: ...; role: ...; tool_call_id: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
ZodObject<
{ content: ...; name: ...; role: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>,
],
>,
| { content: string; role: "system" }
| { content: string | (...)[]; role: "user" }
| { content: string | (...)[]; role: "assistant" }
| {
content: { result: ...; toolCallId: ...; toolName: ...; type: ... }[];
role: "tool";
},
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodOptional<(...)>;
tool_calls: ZodOptional<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
role: ZodLiteral<(...)>;
tool_call_id: ZodString;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodNullable<(...)>;
name: ZodString;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>
| objectInputType<
{
content: ZodUnion<(...)>;
name: ZodOptional<(...)>;
role: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodDiscriminatedUnion<
"type",
[
ZodObject<
{ text: ZodString; type: ZodLiteral<(...)> },
"strip",
ZodTypeAny,
{ text: string; type: "text" },
{ text: string; type: "text" },
>,
ZodObject<
{
image: ZodString;
mimeType: ZodOptional<(...)>;
type: ZodLiteral<(...)>;
},
"strip",
ZodTypeAny,
{ image: string; mimeType?: (...)
| (...); type: "image" },
{ image: string; mimeType?: (...) | (...); type: "image" },
>,
ZodObject<
{
args: ZodType<(...), (...), (...)>;
toolCallId: ZodString;
toolName: ZodString;
type: ZodLiteral<(...)>;
},
"strip",
ZodTypeAny,
{
args: JSONLiteral;
toolCallId: string;
toolName: string;
type: "tool-call";
},
{
args: JSONLiteral;
toolCallId: string;
toolName: string;
type: "tool-call";
},
>,
ZodObject<
{
result: ZodType<(...), (...), (...)>;
toolCallId: ZodString;
toolName: ZodString;
type: ZodLiteral<(...)>;
},
"strip",
ZodTypeAny,
{
result: JSONLiteral;
toolCallId: string;
toolName: string;
type: "tool-result";
},
{
result: JSONLiteral;
toolCallId: string;
toolName: string;
type: "tool-result";
},
>,
],
>,
ZodEffects<
ZodUnion<
[
ZodLiteral<"auto">,
ZodLiteral<"none">,
ZodLiteral<"required">,
ZodObject<
{ function: ...; type: ... },
"strip",
ZodTypeAny,
{ function: ...; type: ... },
{ function: ...; type: ... },
>,
],
>,
"none" | "auto" | "required" | { toolName: string; type: "tool" },
| "none"
| "auto"
| "required"
| { function: { name: string }; type: "function" },
>,
ZodObject<
{
args: ZodType<JSONLiteral, ZodTypeDef, JSONLiteral>;
toolCallId: ZodString;
toolName: ZodString;
type: ZodLiteral<"tool-call">;
},
"strip",
ZodTypeAny,
{
args: JSONLiteral;
toolCallId: string;
toolName: string;
type: "tool-call";
},
{
args: JSONLiteral;
toolCallId: string;
toolName: string;
type: "tool-call";
},
>,
ZodEffects<
ZodObject<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
"passthrough",
ZodTypeAny,
objectOutputType<
{
function: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>,
objectInputType<
{
function: ZodObject<(...), (...), (...), (...), (...)>;
type: ZodLiteral<(...)>;
},
ZodTypeAny,
"passthrough",
>,
>,
{
description?: string;
parameters: {
_type?: unknown;
jsonSchema?: Record<(...), (...)>;
validate?: unknown;
};
type: "function";
},
objectInputType<
{
function: ZodObject<
{ description: ...; name: ...; parameters: ... },
"passthrough",
ZodTypeAny,
objectOutputType<(...), (...), (...)>,
objectInputType<(...), (...), (...)>,
>;
type: ZodLiteral<"function">;
},
ZodTypeAny,
"passthrough",
>,
>,
ZodTypeAny,
>;
}[TargetProviderSDK]["toolCalls"]["fromOpenAI"],
>
the tool call in the target provider format
Converts a tool call to a target provider format