# Custom HTTP APIs

Your agent can answer "Is it cold in Berlin right now?" from a weather API, even when the API has no MCP server. Describe the API's endpoints in a file, and each one becomes a tool the agent can call.

This page uses [Open-Meteo](https://open-meteo.com), a weather API that needs no key.

## Add an API

If you don't have an agent named `support` yet, create one with `getstream agents init support --template blank`. An agent from the text template answers only about its own company, so this page starts from the blank template. For more about agents, see [Creating an agent](https://getstream.io/agents/docs/creating-an-agent/#text-agent).

Write the connector file from its template:

```sh
getstream agents connectors init open_meteo
```

The command writes `connectors/http/open_meteo.yaml` and, once, `connectors/connector.schema.json` for the editor. Replace the file's contents with one tool for Open-Meteo's forecast:

```yaml title="connectors/http/open_meteo.yaml"
# yaml-language-server: $schema=../connector.schema.json
id: custom_open_meteo
name: open_meteo
description: Weather forecasts for any place on Earth.

base_url: https://api.open-meteo.com

tools:
  - name: get_forecast
    description: The current weather at a latitude and longitude.
    method: GET
    path: /v1/forecast
    parameters:
      latitude:
        type: number
        description: Latitude in degrees, such as 52.52
      longitude:
        type: number
        description: Longitude in degrees, such as 13.41
      current:
        type: string
        description: Comma-separated variables, such as temperature_2m,wind_speed_10m
    read_only: true
```

Each tool calls `base_url` plus its `path`, and a `GET` tool's parameters go into the query string. The model reads each `description` to decide when to call the tool and what to pass.

Send the file to Stream:

```sh
getstream agents connectors sync open_meteo
```

```text
Synced connectors/http/open_meteo.yaml as custom_open_meteo, revision 1
```

Connect it and add it to the agent. Open-Meteo needs no key, so the connection is ready to use at once:

```sh
getstream agents connections create custom_open_meteo --label open_meteo --agent support
```

The command adds this entry to `agents/support/agent.yaml` and syncs the agent. Commit `agents/support/agent.yaml` and `connectors/http/open_meteo.yaml`.

```yaml title="agents/support/agent.yaml"
# ...
connectors:
  - name: open_meteo
    connector: custom_open_meteo
    connection: open_meteo
```

Try it:

```sh
getstream agents test support --text
```

Ask: "What is the temperature in Berlin right now?" The CLI prints `Tool open_meteo__get_forecast ran`, and the agent answers with the temperature.

## An API that needs a key

GitHub's code search needs a key: a personal access token. Set `auth.header` to the name of the header the key goes in. The file holds only that name, never the key.

```yaml title="connectors/http/github_code.yaml"
# yaml-language-server: $schema=../connector.schema.json
id: custom_github_code
name: github_code
description: Search code in GitHub repositories.

base_url: https://api.github.com

auth:
  header: Authorization

tools:
  - name: search_code
    description: Search code on GitHub. Add repo:owner/name to search one repository.
    method: GET
    path: /search/code
    parameters:
      q:
        type: string
        description: The search query, such as "useRouter repo:vercel/next.js"
    read_only: true
```

Sync it, then put your [personal access token](https://github.com/settings/tokens) in the `GITHUB_TOKEN` environment variable and save the key with the connection:

```sh
getstream agents connectors sync github_code
getstream agents connections create custom_github_code --label github_code \
  -H Authorization=env:GITHUB_TOKEN --agent support
```

A header named `Authorization` sends the key as a bearer token. Any other header, such as `x-api-key`, sends the key as it is.

Run `getstream agents test support --text` and ask: "Which file in vercel/next.js defines useRouter?" The CLI prints `Tool github_code__search_code ran`.

Stream doesn't try the key until a tool calls the API. A wrong key shows up on the first call, as in [Troubleshooting](https://getstream.io/agents/docs/connectors/troubleshooting/#a-conversation-has-no-tools-from-a-connector). To save another key:

```sh
getstream agents connections update github_code -H Authorization=env:GITHUB_TOKEN
```

## Read-only tools

Set `read_only: true` on a tool that only reads. Only a `GET` tool can be read-only, and sync refuses any other. For example, with `method: POST` on `get_forecast`:

```text
Error: connectors/http/open_meteo.yaml:23: a read-only tool must be GET or HEAD, and "get_forecast" is POST
```

Leave `read_only` out for a tool that changes something. The READS ONLY column shows which tools only read:

```sh
getstream agents connections tools open_meteo
```

```text
TOOL          READS ONLY  NEEDS SCOPES
get_forecast  yes
```

## Change a tool

Edit the file and sync it again. Each sync that changes the file stores a new revision:

```sh
getstream agents connectors sync open_meteo
```

```text
Synced connectors/http/open_meteo.yaml as custom_open_meteo, revision 2
```

A connection keeps the revision it was created with until you move it to the new one. To move a connection that has a key, run `getstream agents connections update` with the key again, as above. The connection then reads the new revision. A connection with no key cannot be updated, so take it off the agent, delete it and create it again:

```sh
getstream agents connectors unbind support open_meteo
getstream agents connections delete open_meteo
getstream agents connections create custom_open_meteo --label open_meteo --agent support
```

## Limitations

- A long answer is cut, and ends with `[connector result truncated]`. Ask the API for only what the model needs, such as fewer variables.
- A tool call has 5 seconds. A longer call is cut, and the model reads that the tool did not answer in time and may or may not have done what was asked.

## Remove an API

```sh
getstream agents connectors remove open_meteo --agent support
```

The command takes the tools off the agent, removes the connector and its connections from your app, and deletes its file.

## Going further

- [Custom MCP servers](https://getstream.io/agents/docs/connectors/mcp/): Any MCP server: a public one, or one behind a key.
- [Tools](https://getstream.io/agents/docs/connectors/choosing-tools/): See a connection's tools and offer only the ones the agent needs.
- [App connection](https://getstream.io/agents/docs/connectors/shared-account/): One account the app owns, for every conversation.
- [Creating an agent](https://getstream.io/agents/docs/creating-an-agent/): The agent folder, and every key of agent.yaml.
- [Troubleshooting](https://getstream.io/agents/docs/connectors/troubleshooting/): Errors you may see, why, and what to do.

---

For the most recent version of this documentation, visit [https://getstream.io/agents/docs/connectors/http/](https://getstream.io/agents/docs/connectors/http/).