yr.tool_creds

tool_creds() → ToolCreds

Return the active tool's credentials.

Call from inside a @tool-decorated function to read the credentials the tool declared with creds=.... The returned ToolCreds is a read-only snapshot of the configured credential groups, flattened to dotted keys.

Examples

Read a credential declared by the currently executing tool:

python
import yera as yr

@yr.tool(creds="weather")
def weather_headers() -> dict[str, str]:
    api_key = yr.tool_creds().require("weather.api_key")
    return {"Authorization": f"Bearer {api_key}"}

Returns

type: ToolCreds

The active tool's credential snapshot.

Raises

RuntimeError

When called outside an active tool invocation.