# Tool Calling

For more advanced use cases, you will probably want to give the LLM a way to interact with its environment. Tool calling enables this by specifying a set of actions the model can take.

Orpheus supports tool calling via the `Tool` object builder, which you can then pass to the `tools` parameter of your request.

The response will then, if the model decides to use a tool, hold a vector of `ToolCall` objects that we can then use within our code.&#x20;

{% code title="empty\_tool.rs" %}

```rust
use orpheus::prelude::*;

fn main() {
    let client = Orpheus::from_env().unwrap();

    // Define a tool
    // For this example, it's just an empty tool we can use as a "switch".
    let my_tool = Tool::function("my_tool").empty();

    let res = client
        .chat("Call my tool")
        .model("openai/gpt-4o")
        .tools([my_tool]) // Pass an iterable of tools to the request
        .send()
        .unwrap();

    // `tool_calls` is a convenience method to
    // access tool calls in the response, if any
    if let Some(tool_calls) = res.tool_calls().unwrap() {
        for tool_call in tool_calls {
            println!("Tool call: {:?}", tool_call);
        }
    }
}
```

{% endcode %}

```
Tool call: Function { id: "call_dTmBXTw3BXhIbCL5r2dVvnnU", function: Function { name: "my_tool", arguments: "{}" } }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://orpheus.ajac-zero.com/features/tool-calling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
