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

# Rork

Give your Rork app live web search and page reading: store your SpecStream key as a server side secret, then ask Rork for a server function that calls the SpecStream Search API. The key never ships inside the app, and each search costs $5 per 1,000.

[SpecStream for RorkAgent frameworks & builders](https://specstream.ai/integrations/rork.md)

## What you need

-   A Rork project. Rork Cloud, or your own Supabase project, runs the server function.
-   A SpecStream account. New accounts get $10 of credit on sign up, no card. [Create one](https://specstream.ai/signup?utm_source=rork).

1.  1

    ## 1. Create a key for the app

    In the SpecStream workspace, open [Agents & API](https://specstream.ai/workspace/agents?tab=keys&utm_source=rork), choose **API keys**, then **Create API key**, and label it for the app. Keep the permissions that are already on, because a search spends from your balance.

    Click **Set a total limit** and enter the most the app may spend for all its users together. The key expires after 30 days unless you raise **Expires after, days**. Copy the key from the next screen. SpecStream shows it once.

2.  2

    ## 2. Add the key to Rork's Secrets

    In your Rork project, open **More**, then **Secrets**, and press **Add Variable**. Enter `SPECSTREAM_API_KEY` as the **Key**, paste your key as the **Value**, and press **Save**.

    Check that the label under the key reads **Server-side only**. Rork ships every variable whose name starts with `EXPO_PUBLIC_` inside the app, where anyone who installs it can read it, so never give this key that prefix.

    When Rork asks for a key in the chat instead, paste it into the card's field and press **Save & Continue**.

3.  3

    ## 3. Ask Rork for the server function

    Describe the feature and name the secret. If the project has no backend yet, Rork shows a **Create Rork Cloud** card first. Rork's docs suggest attaching the provider's documentation, so the prompt links SpecStream's:

    In the Rork chat

    ```text
    Add a search screen. When the user submits a question, call a server function, never the app itself, that sends GET https://api.specstream.ai/v1/web-search?q=<the question> with the header Authorization: Bearer <SPECSTREAM_API_KEY>, read from the server side secret. Show data.answer.value with a link to data.answer.page when the answer is not null, then each item of data.sources with its title, url and snippet. Send the signed in user's ID as X-End-User-Id. API reference: https://specstream.ai/agents.md
    ```

4.  4

    ## 4. Test it in the preview

    Ask a question that needs today's web on the new screen. If nothing comes back, open the **Logs** panel, or ask Rork to log the call to the API so it can see SpecStream's status code and message. The table below says what each code means.

## What the function gets back

Every reply is `{"data": {...}}`. For a question with one answer, `data.answer` holds the `value` as the pages print it, the `page` it was read from and its read time in `seen_at`. `data.sources` lists the search results read, each with `url`, `title`, `site` and `snippet`, and `published` when the page states its date. `data.price_usd` is what the call cost.

Add `speed=fast` to the address for search results alone, with no answer, at $1 per 1,000 searches. Add `num` (1 to 100) for more results in one call.

## Reading pages

For the text of pages, ask Rork for a second server function that sends `POST https://api.specstream.ai/v1/extract` with `{"urls": ["<url>"]}`, up to 20 URLs a call, and the same header. Each page comes back in `data.results` with its `text`, `title` and `status`. See the [Extract API](https://specstream.ai/docs/extract-api.md).

## When a call fails

| Status | What it means |
| --- | --- |
| `401` | No key was sent (`missing_api_key`), or the key is unknown, expired or revoked (`invalid_token`). Check the secret's name in the function. |
| `402` | The balance is empty, the call would go over the account's monthly spending limit, or it would go over that user's monthly cap. |
| `403` | The call would go over the key's total limit. |
| `422` | `q` is empty or longer than 2,000 characters. |
| `503` | The account used its calls for the minute. Wait the seconds in `Retry-After` and send it again. Nothing is charged. |

## Who pays

The published app runs every search on the key in its secret, so every user spends from your SpecStream account, and the key's total limit caps what the app can spend. To cap one user, the function also sends `X-End-User-Cap-Cents` with `X-End-User-Id`, and a call past that user's monthly cap is refused.

This is separate from Rork's credits. Rork AI Cloud in your apps is paid from the project owner's Rork credits. A SpecStream search is paid from your SpecStream balance.

## Cost

A search of up to 10 results is $5 per 1,000, and $1 per 1,000 with `speed=fast`. A search that returns no results costs nothing. A page read is $0.80 per 1,000 pages, and a page that gives no text is not charged. Each call comes out of your balance with no quote and no approval, and every call is in your account's request log. [Pricing](https://specstream.ai/pricing.md) has the details.

## Lists of records

For an app that needs every match on the live web as structured rows, use Deep Search through the [API](https://specstream.ai/docs/api.md). It reads the request, prices it, and runs only after the price is approved.

## Remove

Revoke the key under **Agents & API** in your SpecStream workspace first: that stops it at once. Then delete `SPECSTREAM_API_KEY` in Rork's **Secrets** and ask Rork to remove the function. Questions go to [support@specstream.ai](mailto:support@specstream.ai).

## More

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