# brapi.dev GPT Action

Use this guide to connect a Custom GPT to the read-only brapi Brazilian financial data API.

## OpenAPI schema

Import this schema in the GPT Action editor:

- https://brapi.dev/swagger/gpt.json

The schema contains 28 common operations. It stays below ChatGPT's 30-operation limit.

## OAuth 2.0

Configure the action with these values:

- Authorization URL: https://brapi.dev/oauth/authorize
- Token URL: https://brapi.dev/oauth/token
- Scope: mcp:read
- Token exchange method: Default (POST request)
- Privacy policy: https://brapi.dev/privacy-policy

The flow reuses brapi's MCP OAuth issuer and access-token validation. The GPT action sends the access token as `Authorization: Bearer TOKEN` to protected REST endpoints.

## Register the GPT client

Replace `GPT_ID` with the ID in the GPT editor URL. Register both supported ChatGPT callback domains:

~~~bash
curl -X POST https://brapi.dev/oauth/register \
  -H 'Content-Type: application/json' \
  -d '{
    "redirect_uris": [
      "https://chatgpt.com/aip/GPT_ID/oauth/callback",
      "https://chat.openai.com/aip/GPT_ID/oauth/callback"
    ],
    "client_name": "brapi GPT",
    "token_endpoint_auth_method": "client_secret_post",
    "scope": "mcp:read"
  }'
~~~

Copy `client_id` and `client_secret` into the GPT Action OAuth settings. Keep the client secret private. The registration response returns it only once.

## Use the action

- Ask for a current quote with a B3 ticker, such as PETR4 or VALE3.
- Ask for historical prices, dividends, financial statements, FIIs, exchange rates, crypto, inflation, Selic, or Treasury indicators.
- Use symbols separated by commas for multiple assets.
- Use the sandbox tickers PETR4, VALE3, MGLU3, and ITUB4 before authenticated requests.
- Treat returned data as informational, not financial advice.

## Related resources

- https://brapi.dev/llms.txt
- https://brapi.dev/developers
- https://brapi.dev/openapi.json
- https://brapi.dev/docs/mcp
