# `Nous.ToolSchema`
[🔗](https://github.com/nyo16/nous/blob/v0.17.1/lib/nous/tool_schema.ex#L1)

Convert tools to different schema formats for various providers.

Different LLM providers expect different tool schema formats:

- **OpenAI format**: String keys, function wrapper
- **Anthropic format**: Atom keys, input_schema field
- **Custom providers**: May require format-specific adaptations

## Examples

    # Convert to OpenAI format (used by OpenAI, Groq, OpenRouter, local providers)
    openai_schema = ToolSchema.to_openai(tool)
    # Returns: %{"type" => "function", "function" => %{"name" => "...", ...}}

    # Convert to Anthropic format (used by Claude)
    anthropic_schema = ToolSchema.to_anthropic(tool)
    # Returns: %{name: "...", description: "...", input_schema: %{type: :object, ...}}

The schema conversion preserves all tool metadata while adapting to provider requirements.

# `to_anthropic`

```elixir
@spec to_anthropic(Nous.Tool.t()) :: map()
```

Convert tool to Anthropic tool schema (atom keys).

Anthropic uses a different format with atom keys:
%{
  name: "tool_name",
  description: "Tool description",
  input_schema: %{
    type: "object",
    properties: %{...},
    required: [...]
  }
}

# `to_gemini`

```elixir
@spec to_gemini(Nous.Tool.t()) :: map()
```

Convert tool to Gemini/Vertex `functionDeclarations` schema (string keys).

Vertex/Gemini's function declaration is shaped like OpenAI's inner `function`
object, minus the `strict` field which is OpenAI-specific.

Returns:

    %{
      "name" => "...",
      "description" => "...",
      "parameters" => %{...}
    }

# `to_openai`

> This function is deprecated. Use Nous.Tool.to_openai_schema/1 directly.

```elixir
@spec to_openai(Nous.Tool.t()) :: map()
```

Convert tool to OpenAI function calling schema (string keys).

Deprecated alias — call `Nous.Tool.to_openai_schema/1` directly. This
module's `to_anthropic/1` and `to_gemini/1` are the actively used
conversions; `to_openai/1` is only kept for backward compatibility.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
