> SpecStream is the live web data engine for teams and agents. This is the Markdown copy of https://specstream.ai/docs/integrations/fyin. Every page, with what SpecStream does and costs: https://specstream.ai/llms.txt

# Fyin

Set `BING_ENDPOINT` in Fyin's `.env` to SpecStream's Bing Web Search v7 address and put your SpecStream key in `BING_SUBSCRIPTION_KEY`. Fyin's Bing code stays as it is, and every question searches the live web through SpecStream's Search API, at $1 per 1,000 searches of up to 10 results.

[SpecStream for FyinAI assistants](https://specstream.ai/integrations/fyin.md)

## What you need

-   Fyin from GitHub, built with Rust and Cargo or with Docker. An OpenAI key, or Ollama running on the same machine.
-   A SpecStream key. [Get your key](https://specstream.ai/workspace/search?route=bing&utm_source=fyin&utm_medium=howto) on the Search API screen of your SpecStream workspace. New accounts start with $10 of credit, no card.

1.  1

    ## 1. Clone Fyin and add the search module

    The README's clone address names `fyin.app`. The repository is `shadowfax92/Fyin`.

    On the `main` branch, `src/main.rs` declares `mod search;` and calls `search::fetch_web_pages`, while the search code is still in `src/bing.rs`. `cargo build` then stops with `file not found for module search`. Copy the file to the name `main.rs` asks for:

    Terminal

    ```bash
    git clone https://github.com/shadowfax92/Fyin.git
    cd Fyin
    cp src/bing.rs src/search.rs
    ```

2.  2

    ## 2. Create .env from sample.env

    Fyin loads its settings with `dotenv`, which reads `.env` in the folder you run Fyin from. The README says to copy `sample.env` to `.fyin.env`, but `dotenv` does not read that name. Copy it to `.env`:

    Terminal

    ```bash
    cp sample.env .env
    ```

3.  3

    ## 3. Set the search lines

    In `.env`, set the three search lines below, with your key in place of `YOUR_SPECSTREAM_KEY`. `BING_ENDPOINT` takes the whole search address: Fyin sends its `GET` to that address as it is.

    Do not leave `BING_ENDPOINT` blank. The sample's `Leave blank for default` sets an empty address, and Fyin's code uses its built-in Microsoft address only when the line is missing. Write every value in `.env` without quote marks, so the same file also works with Docker's `--env-file`.

    .env

    ```bash
    SEARCH_ENGINE=bing
    BING_ENDPOINT=https://api.specstream.ai/v7.0/search
    BING_SUBSCRIPTION_KEY=YOUR_SPECSTREAM_KEY
    ```

4.  4

    ## 4. Set the model lines

    Fyin checks that `OPENAI_API_KEY`, `BING_SUBSCRIPTION_KEY`, `EMBEDDING_MODEL_NAME` and `CHAT_MODEL_NAME` are set and not empty before it starts.

    With OpenAI, set `OPENAI_API_KEY` to your OpenAI key and keep `OPENAI_BASE_URL` empty, `EMBEDDING_MODEL_NAME=text-embedding-ada-002` and `CHAT_MODEL_NAME=gpt-4o` as in the sample.

    With Ollama, use the values in the sample's comments: `OPENAI_API_KEY=ollama`, `OPENAI_BASE_URL=http://localhost:11434/v1`, and `llama3` for both model names. An address with `localhost` in it puts Fyin in local mode, and it prints `Running in local mode using ollama`.

5.  5

    ## 5. Ask a question

    Pass the question with `--query`, and the number of results with `--search` (or `-s`), 10 by default. The README's `-n` is not a flag Fyin defines. After `cargo run`, put `--` before Fyin's own flags:

    Terminal

    ```bash
    cargo run --release -- --query "What changed in the Rust 2024 edition?" --search 10
    ```

6.  6

    ## 6. Check the search

    Fyin prints `Fetching search results from bing...`, then `Search returned: 10 results`. It reads each page it found, then streams the answer from your model.

## What Fyin sends, and what comes back

| Fyin sends | SpecStream |
| --- | --- |
| `GET` to `BING_ENDPOINT` | `https://api.specstream.ai/v7.0/search`, the path of Bing Web Search v7 |
| The `Ocp-Apim-Subscription-Key` header, from `BING_SUBSCRIPTION_KEY` | Your SpecStream key, read from the same header |
| `q`, your question | Searched on the live web as written |
| `count`, from `--search` | That many results, up to 50 |
| `mkt=en-US` | Read as English results for the United States |
| Reads `webPages.value[]`, with `name` and `url` | Bing's JSON: `webPages.value[]` with `name`, `url` and `snippet` |

## Why the Bing setting

Microsoft retired the Bing Search APIs on August 11, 2025, so the default address in Fyin's code no longer answers. See [the move from Bing Web Search v7](https://specstream.ai/migrate/bing-web-search-v7.md).

`sample.env` also lists `searxng` and `duckduckgo`, but Fyin's search code reads `webPages.value` from every reply. That is Bing's field, and a SearXNG or DuckDuckGo reply does not have it, so Fyin stops on those replies. SpecStream answers in Bing's shape, so the Bing setting works with no change to Fyin's code.

## Run it in Docker

The Dockerfile copies `src` into the image, so make the `src/search.rs` copy from the first step before you build. Then build the image and pass `.env` to the container:

## What each question costs

Each question is one Search API call on the fast tier: $1 per 1,000 searches of up to 10 results, a fifth of the default search's $5. Each started block of 10 more results adds $0.0012, so `--search 20` costs $0.0022.

Fyin reads the pages it found by itself, from your machine, so page reading costs nothing on SpecStream. A call that returns no results costs nothing. Searches come out of your balance, with no quote and no approval. New accounts start with $10 of credit, no card.

## Limits and errors

-   `Failed to retrieve 'OPENAI_API_KEY'` means Fyin found no `.env`. Run it from the folder that holds the file.
-   `Request failed with status code: 401 Unauthorized` means SpecStream got no valid key. Check `BING_SUBSCRIPTION_KEY` in `.env`, and that the key was made on the Search API screen.
-   `Request failed with status code: 429 Too Many Requests` means search was busy. SpecStream answers with `Retry-After` and charges nothing. Ask again after a moment.
-   A `builder error` from `reqwest` means `BING_ENDPOINT` is empty. Set it to the whole address in the step above.

## Read pages and get rows too

The same key reads pages with the [Extract API](https://specstream.ai/docs/extract-api.md) at $0.80 per 1,000 pages, and a page with no text is not charged. For a dataset, add SpecStream's MCP server at `https://api.specstream.ai/mcp` to an MCP client and ask for the records in plain words. Deep Search returns every match as structured rows at 5¢, 15¢ or $1 a row, under a maximum you approve. See [MCP](https://specstream.ai/docs/mcp.md).

## Remove

Set `BING_ENDPOINT` and `BING_SUBSCRIPTION_KEY` in `.env` to another provider's values. To end the key's access, revoke it under **API keys** in **Agents & API** in your workspace. Questions go to [support@specstream.ai](mailto:support@specstream.ai).

## More

[SpecStream for Fyin](https://specstream.ai/integrations/fyin.md) covers what it does in Fyin on one page. Every other tool has its guide in [Connect your tools](https://specstream.ai/docs/integrations.md). You see the most a request can cost before it starts, and the matches are paid from your balance. [Billing](https://specstream.ai/docs/billing.md) has the details. For help, email [support@specstream.ai](mailto:support@specstream.ai).
