Skip to main content
By the end of this guide you will have a script that pulls live Hyperliquid market data, sends it to a model through the OpenFinance inference API, and prints a short brief, all with your one OpenFinance key. The inference API is an OpenAI-compatible endpoint at https://api.openfinance.tech/agent/v1. It returns text and is billed in AI credits. It cannot trade by itself. The MCP server gives code the market data and trading tools. This guide uses the inference API for the model and only read actions from the MCP server, so the script never places an order.

What you need

Steps

1

Store the key in your environment

The same key trades and moves funds, so keep it on your machine or server only. Never put it in a browser app, a mobile app or a repository.
2

Check credits and pick a model

Look at availableCredits, then choose a model id from the list. Ids use a provider/model form. A smaller model is enough while you test.
3

Install the two client libraries

4

Write the script

Save this as brief.mts (the .mts ending lets it use top-level await):
5

Run it

You should see a short list of perps with funding rates and open interest. This uses AI credits and places no trades.
6

Check what it cost

Run the credits call from step 2 again and compare usageCredits. Larger models and longer inputs cost more.

Make it yours

  • Change the data. Swap the action: get_perp_categories for HIP-3 markets, or the polymarket tool with search for prediction markets. Every action is listed in the tool reference.
  • Run it on a schedule with cron or your host’s scheduler, and send the output to wherever you read it.
  • Stream the reply by setting stream: true. See Examples.

Keep it read-only

A script that only summarizes should only call read actions. If you later add trading, show a summary to a person and wait for a yes before each write, the same rule the OpenFinance tools follow. Every trade needs the user’s confirmation, and nothing a model writes is financial advice.

Check it worked

  • The script prints a summary that matches what the chat says for the same markets.
  • Your credit usage went up by a small amount.

Common mistakes

  • Rejected for an invalid key. Check that the value starts with open_. Either Authorization: Bearer or x-api-key works on the inference API.
  • Rejected for insufficient credits. Top up in the app and retry.
  • Sending a huge payload. Trim market data before you send it. Credits scale with input length.
  • A 429. You are calling too fast. Slow the loop down.
  • Hard-coding a model list. Read ids from GET /models; the list changes.

Next guides

Build a trading dashboard or bot

Let Build mode write the app for you.

Inference examples

curl, Python and streaming.