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

# Rocket

Import SpecStream into a Rocket app from the APIs panel: one cURL command for web search, one for page reading, and one for Deep Search rows, with your key kept in the environment.

[SpecStream for RocketCoding agents](https://specstream.ai/integrations/rocket.md)

## What you need

-   A Rocket web build task. Rocket imports APIs in the web browser only, not in its mobile app.
-   A SpecStream API key. New accounts get $10 of credit on sign-up, no card. [Create one](https://specstream.ai/signup?utm_source=rocket).

1.  1

    ## 1. Create a key and store it in Rocket

    In SpecStream, open [Agents & API](https://specstream.ai/workspace/agents?tab=keys&utm_source=rocket), choose **API keys**, then **Create API key**. Give it the `finds:spend` scope and a total spending limit: the limit is the most the app can ever spend.

    In Rocket, click **Code** in the editor toolbar, open `.env` at the root of the project, and add the variable with a placeholder. Then click your task name, **Settings**, and under **Task** click **Environment**. Use the edit icon on the row to put the real key in both the **Staging** and **Production** tabs.

    Never name it with the `NEXT_PUBLIC_` prefix. Rocket sends those variables to the browser, and the key must stay on the server.

    .env

    ```bash
    SPECSTREAM_API_KEY=your-key-here
    ```

2.  2

    ## 2. Open the APIs panel

    Click the **...** button in the preview toolbar and select **APIs**. Open the **Select an API** dropdown and click **Add APIs**, then choose the **cURL** tab.

3.  3

    ## 3. Import web search

    Paste this command and click **Add API**. After the import, map `$SPECSTREAM_API_KEY` to the environment variable, so the header reads `Authorization: Bearer` and then your key.

    The reply is `{"data": {...}}`. `data.answer` holds the value when the question has one answer, and `data.sources` lists the pages read, each with `url`, `title` and `snippet`. Each call costs $5 per 1,000 searches of up to 10 results, and a call that returns nothing costs nothing.

    cURL tab: Search API

    ```bash
    curl "https://api.specstream.ai/v1/web-search?q=coworking+spaces+in+Lisbon&num=10" \
      -H "Authorization: Bearer $SPECSTREAM_API_KEY"
    ```

4.  4

    ## 4. Import page reading

    Add a second API the same way. It reads up to 20 URLs a call and returns each page's main text as Markdown, with its `title` and `status`, in `data.results`.

    Each page read costs $0.80 per 1,000 pages. A page that gives no text is not charged.

    cURL tab: Extract API

    ```bash
    curl -X POST "https://api.specstream.ai/v1/extract" \
      -H "Authorization: Bearer $SPECSTREAM_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"urls": ["https://example.com"], "format": "markdown"}'
    ```

5.  5

    ## 5. Attach a call to a screen

    In the APIs panel, choose the **route** the call belongs to, select the SpecStream API in **Select an API**, and click **Integrate API**. Click a container that is always on the screen, not one that appears only after a click.

    In the **When to call this API?** dialog, fill in the three fields as below and click **Submit**. Rocket writes the integration code.

    When to call this API?

    ```text
    When should this API run: On click of the Search button
    
    Pre API call Instructions: Read the query from the search input and stop if it is empty. Call SpecStream from server code with SPECSTREAM_API_KEY from the environment, and never send the key to the browser.
    
    Post API call Instructions: Store data.sources in a state variable named results and show title, url and snippet for each. On 402, show that the SpecStream balance is empty. On 503, wait the seconds in Retry-After and try once more.
    ```

## Deep Search: rows for tables and enrichment

For a table, such as every company that meets your conditions with the columns you name, import `POST /v1/capacity/requests`. SpecStream reads the request, prices it, and starts it only when the price is at or below `confirm_max_cents`. Above it, nothing runs. `idempotency_key` is 8 to 128 characters, new for each request, so a repeated call returns the run already started.

To see the price first, send `confirm_max_cents` of `1`. The state comes back `above_maximum`, with the price in `maximum_cents`. Send that price with a new key to start.

To enrich rows you already have, send them in `rows` (each company's name, website or domain) and what to bring back in `fields`.

Read the rows with `GET /v1/capacity/requests/YOUR_KEY/rows`, imported the same way. Each delivered row costs 5¢, 15¢ or $1, depending on how much it needs. Duplicates and rows a page contradicts are not charged, and a run that finds nothing costs nothing. The key needs the `specs:write`, `finds:write` and `finds:spend` scopes.

## Or import the whole API from its OpenAPI spec

Save [openapi.json](https://specstream.ai/openapi.json). It is OpenAPI 3.1.0 with one server, `https://api.specstream.ai`, and Bearer authentication. In **Add APIs**, choose **Swagger**, upload the file, and click **Submit**.

The spec holds every SpecStream endpoint, so the **Select an API** list gets long. The cURL imports above add only the calls an app needs.

## If your app calls Firecrawl today

Rocket's connectors page lists Firecrawl among the APIs its community connected with the importer. An app that already calls Firecrawl's v2 API keeps its code: change the base address to `https://api.specstream.ai/firecrawl` and the key to your SpecStream key.

`/v2/search` is then one web search, answered in Firecrawl's shape, and `/v2/scrape` is one Extract API page at $0.80 per 1,000 pages. [Moving from Firecrawl](https://specstream.ai/migrate/firecrawl.md) lists every route.

## When a call fails

-   `401`: the header is missing or not in the form `Bearer <key>`. Check the mapping of `$SPECSTREAM_API_KEY` in the Pre API call instructions.
-   `402`: the balance is empty, or the call would pass the account's monthly limit.
-   `403`: the key lacks the `finds:spend` scope, or the call would pass the key's own limit.
-   `503` with `Retry-After`: the account used its calls for the minute. Wait that many seconds. Nothing is charged.

## Cost

Importing SpecStream into Rocket costs nothing. Searches and pages come out of the balance as the app runs them, with no quote. Deep Search never costs more than the `confirm_max_cents` you send. [Balance, quotes, and billing](https://specstream.ai/docs/billing.md) has the details, and the [API reference](https://specstream.ai/docs/api.md) has every field.

## Disconnect

Revoke the key under **Agents & API** > **API keys** in SpecStream, and every call from the app stops at once. Then remove the API from the Rocket project and the variable from **Environment**. Your saved results stay in your workspace. Questions go to [support@specstream.ai](mailto:support@specstream.ai).

## More

[SpecStream for Rocket](https://specstream.ai/integrations/rocket.md) covers what it does in Rocket 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).
