Mirascope Frog Logo
Mirascope
DocsBlogPricingCloud
⌘K
Type to search
⌘Kto search
Escto close
mirascope
v2.0.2
1.4k
Join our
WelcomeLearnGuidesAPI Referencev1 (Legacy)
DocsGuidesAPI
Overview
Core
CallCall ParamsCall ResponseCall Response ChunkDynamic ConfigStreamTool
Llm
CallCall ResponseCall Response ChunkContextOverrideStreamTool
Mcp
Client
Retries
FallbackTenacity
Tools
# mirascope.core.openai.tool ## <ApiType type="Module" path="core/openai/tool" symbolName="tool" /> tool The `OpenAITool` class for easy tool usage with OpenAI LLM calls. <Info title="Usage"> [Tools](/docs/v1/learn/tools) </Info> ## <ApiType type="Class" path="core/openai/tool" symbolName="GenerateOpenAIStrictToolJsonSchema" /> GenerateOpenAIStrictToolJsonSchema **Bases:** <TypeLink type={{"type_str": "GenerateJsonSchemaNoTitles", "description": null, "kind": "simple", "doc_url": "/docs/v1/api/core/base/tool#generatejsonschemanotitles"}} /> ## <ApiType type="Class" path="core/openai/tool" symbolName="OpenAIToolConfig" /> OpenAIToolConfig A tool configuration for OpenAI-specific features. **Bases:** <TypeLink type={{"type_str": "ToolConfig", "description": null, "kind": "simple", "doc_url": "/docs/v1/api/core/base/tool#toolconfig"}} /> <AttributesTable attributes={[ { "name": "strict", "type_info": { "type_str": "bool", "description": null, "kind": "simple", "doc_url": "https://docs.python.org/3/library/functions.html#bool" } } ]} /> ## <ApiType type="Class" path="core/openai/tool" symbolName="OpenAITool" /> OpenAITool A class for defining tools for OpenAI LLM calls. Example: ```python from mirascope.core import prompt_template from mirascope.core.openai import openai_call def format_book(title: str, author: str) -> str: return f"{title} by {author}" @openai_call("gpt-4o-mini", tools=[format_book]) def recommend_book(genre: str) -> str: return f"Recommend a {genre} book" response = recommend_book("fantasy") if tool := response.tool: # returns an `OpenAITool` instance print(tool.call()) ``` **Bases:** <TypeLink type={{"type_str": "BaseTool", "description": null, "kind": "simple", "doc_url": "/docs/v1/api/core/base/tool#basetool"}} /> <AttributesTable attributes={[ { "name": "tool_call", "type_info": { "type_str": "SkipJsonSchema[ChatCompletionMessageToolCall]", "description": null, "kind": "generic", "base_type": { "type_str": "SkipJsonSchema", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/json_schema/#pydantic.json_schema.SkipJsonSchema" }, "parameters": [ { "type_str": "ChatCompletionMessageToolCall", "description": null, "kind": "simple", "doc_identifier": "ChatCompletionMessageToolCall" } ] } } ]} /> ## <ApiType type="Function" path="core/openai/tool" symbolName="tool_schema" /> tool_schema Constructs a JSON Schema tool schema from the `BaseModel` schema defined. Example: ```python from mirascope.core.openai import OpenAITool def format_book(title: str, author: str) -> str: return f"{title} by {author}" tool_type = OpenAITool.type_from_fn(format_book) print(tool_type.tool_schema()) # prints the OpenAI-specific tool schema ``` <ParametersTable parameters={[ { "name": "cls", "type_info": { "type_str": "Any", "description": null, "kind": "simple", "doc_identifier": null } } ]} /> <ReturnTable returnType={{ "type_info": { "type_str": "ChatCompletionToolParam", "description": null, "kind": "simple", "doc_identifier": "ChatCompletionToolParam" } }} /> ## <ApiType type="Function" path="core/openai/tool" symbolName="from_tool_call" /> from_tool_call Constructs an `OpenAITool` instance from a `tool_call`. <ParametersTable parameters={[ { "name": "cls", "type_info": { "type_str": "Any", "description": null, "kind": "simple", "doc_identifier": null } }, { "name": "tool_call", "type_info": { "type_str": "ChatCompletionMessageToolCall", "description": null, "kind": "simple", "doc_identifier": "ChatCompletionMessageToolCall" }, "description": "The OpenAI tool call from which to construct this tool instance." }, { "name": "allow_partial", "type_info": { "type_str": "bool", "description": null, "kind": "simple", "doc_url": "https://docs.python.org/3/library/functions.html#bool" }, "default": "False", "description": "Whether to allow partial JSON data." } ]} /> <ReturnTable returnType={{ "type_info": { "type_str": "OpenAITool", "description": null, "kind": "simple", "doc_url": "/docs/v1/api/core/openai/tool#openaitool" } }} />

Provider

On this page

Provider

On this page

© 2026 Mirascope. All rights reserved.

Mirascope® is a registered trademark of Mirascope, Inc. in the U.S.

Privacy PolicyTerms of Use