DSPy Programs for Brazil CVM Filings

Building DSPy CVM filings agents? apicvm exposes resolve, document list, file download, and async text extraction over HTTPS — wire them as tools/nodes, cite document UUIDs.

The problem

LLM graphs hallucinate when filings arrive as scraped HTML blobs. Stable CVM document IDs and typed filters (DFP/ITR/FRE) keep retrieval auditable.

Tool surface

  1. GET /v1/companies/resolve
  2. GET /v1/documents
  3. GET /v1/documents/:id/file
  4. POST /v1/document-text-extractions (async callback)

Example: list FRE for a ticker

export APICVM_URL='https://apicvm.dev'
export APICVM_KEY='apicvm_...'

curl -H "Authorization: Bearer $APICVM_KEY" \
  "$APICVM_URL/v1/documents?ticker=VALE3&type=FRE&year=2024&perPage=20"

Python tool body

import os, requests

BASE = os.environ["APICVM_URL"]
H = {"Authorization": f"Bearer {os.environ['APICVM_KEY']}"}

def list_filings(ticker: str, doc_type: str, year: int):
    return requests.get(
        f"{BASE}/v1/documents",
        headers=H,
        params={"ticker": ticker, "type": doc_type, "year": year, "perPage": 20},
    ).json()["data"]

print([d["id"] for d in list_filings("VALE3", "DFP", 2024)[:3]])

Wrap list_filings as a DSPy tool/node. Prefer returning IDs + names to the model; download PDFs in a separate step.

Current limitations

  • Extraction is async — do not block a graph turn waiting for full markdown unless you implement callback/poll.
  • No embeddings endpoint in v1; bring your own vector store.
  • Rate limits and plan quotas apply; see docs.

Next steps

Ready to integrate?

Get an API key and start querying Brazilian CVM filings programmatically.