# Microsoft Agent Framework (/docs/agent-framework)

`agent-framework-bowmark` gives a [Microsoft Agent Framework](https://github.com/microsoft/agent-framework)
agent the same two calls every Bowmark caller makes: read the function library for a task,
then run a short script against it on the live sites. It also ships the instructions that
tell the model how to use them.
Source: [bowmark-ai/agent-framework-bowmark](https://github.com/bowmark-ai/agent-framework-bowmark).

## Install

```bash
pip install agent-framework-bowmark
export BOWMARK_API_KEY="bmk_..."
```

Make the key at [dashboard/keys](https://bowmark.ai/dashboard/keys). New accounts get $10 of
free usage with no card ([Pricing](/docs/pricing)).

## Use it

```python
import asyncio
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
from agent_framework_bowmark import BowmarkTools

bowmark = BowmarkTools()
agent = Agent(OpenAIChatClient(), instructions=bowmark.instructions, tools=bowmark.tools)

result = asyncio.run(agent.run("What are the top 3 stories on Hacker News right now?"))
print(result.text)
```

## The tools

| Tool                  | What it does                                                                                                                                                |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bowmark_get_library` | Returns the typed functions for a task or a site, with their types and examples. Read-only, free, touches no site. Same as `GET /v1/library`.               |
| `bowmark_run`         | Runs an async JavaScript script against those functions on the live sites and returns `{ ok, status, result, logs, error, runId }`. Same as `POST /v1/run`. |

## Options

| Option     | Default                  | What it does      |
| ---------- | ------------------------ | ----------------- |
| `api_key`  | `BOWMARK_API_KEY`        | Your Bowmark key. |
| `base_url` | `https://api.bowmark.ai` | The API to call.  |

`bowmark.instructions` is plain text: add it to your agent's instructions, or write your own.

A run that fails comes back as an envelope with `error` set, so the model can read it, fix
its script and try again. See [Scripting](/docs/scripting) for what a script can call.
