Skip to main content
Every example below uses the base URL https://api.openfinance.tech/agent/v1 and reads your key from an environment variable. For what the API is and how billing works, see the overview. Set the key once in your shell:

A first request

Here is the same request in curl, Python and TypeScript:
The only differences from a stock OpenAI setup are the key and the base URL. Request and response shapes stay the same.

Streaming

Set stream to true to receive the reply as it is written.

List the models

Use an id from this list as the model value. Ids use a provider/model form.

Check your credits

Look at availableCredits in the response. Top up in the OpenFinance app when it runs low; see Models and AI credits.

Switching from another provider

If your code already uses an OpenAI-compatible client, change two lines:
Then replace the model name with an id from GET /models.

Tips

  • Either header works. Authorization: Bearer open_... suits OpenAI-style clients. x-api-key: open_... matches what you already send to the MCP server.
  • Run it server-side. The key can also trade and move funds, so it must never reach a browser or a mobile app.
  • Handle rejected requests. If a request is rejected for an invalid key, check that the key starts with open_. If it is rejected for insufficient credits, top up and retry.

Next

Inference overview

Endpoints, auth and credits.

MCP overview

Let an AI client trade through OpenFinance.