Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/tools-custom/openapi-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,40 @@ This example demonstrates generating tools from a simple Pet Store OpenAPI spec
```python title="openapi_example.py"
--8<-- "examples/python/snippets/tools/openapi_tool.py"
```
## Advanced Configuration

### Custom Headers with `header_provider`

You can provide a callable to `header_provider` to dynamically add custom headers to every API request. The callable receives the `ReadonlyContext` and should return a dictionary of headers.

```python
def my_header_provider(context: ReadonlyContext) -> dict[str, str]:
return {"X-Request-ID": context.invocation_id}

toolset = OpenAPIToolset(
spec_dict=openapi_spec,
header_provider=my_header_provider,
)
```

### SSL Certificate Verification with `ssl_verify`

You can configure SSL certificate verification for all tools in the toolset using the `ssl_verify` parameter. This is useful for environments with custom CA certificates.

```python
toolset = OpenAPIToolset(
spec_dict=openapi_spec,
ssl_verify="/path/to/ca.pem",
)
```

### Tool Name Prefix with `tool_name_prefix`

You can add a prefix to all tool names generated by the toolset using the `tool_name_prefix` parameter. This is useful for avoiding name collisions when using multiple OpenAPI specs.

```python
toolset = OpenAPIToolset(
spec_dict=openapi_spec,
tool_name_prefix="my_api",
)
```
Loading