Skip to content

docs(llms): send key holders to pro-api for every request - #53

Merged
treeoflife2 merged 12 commits into
mainfrom
claude/fix-agents-use-pro-api
Nov 24, 2026
Merged

treeoflife2 merged 12 commits into
mainfrom
claude/fix-agents-use-pro-api

Conversation

@treeoflife2

@treeoflife2 treeoflife2 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Problem

Paying users reported rate limits with barely any usage. Code written from llms-free.txt called api.llama.fi, coins.llama.fi, stablecoins.llama.fi and yields.llama.fi even when the user said they had a key. Those hosts never read a key, so the requests were free tier.

Changes

  • One "Have an API key? Use pro-api.llama.fi for every request" section, shared by llms.txt, llms-free.txt and llms-pro.txt. It replaces the separate authentication and troubleshooting sections. It has a right and wrong URL example and says: free hosts never read a key, a 429 or 402 there means the wrong host, fallback lookups go to pro-api too, which path prefixes pro-api uses, and that a user with a key uses pro-api whatever they call their plan.
  • llms-free.txt lists the keyed URL under every free endpoint, for example **With an API key:** https://pro-api.llama.fi/{YOUR_API_KEY}/coins/prices/current/{coins}.
  • The docs page without a key showed free operations only on their free hosts (pro twins appear only after entering a key). Each of the 31 free operations in defillama-openapi-free.json now has a description naming its keyed pro-api URL, so readers of the page and of the raw spec see it too.
  • Same message on the static homepage (what a plain fetch of api-docs.defillama.com returns) and in the free spec description.
  • Header and ?apikey= keys are still not read by pro-api: all 10 header formats I tried (Authorization: Bearer, raw Authorization, x-api-key, apikey and others) return 500 {"error":"API Key is wrong"} with a valid key. The docs quote that error so it is not read as a bad key.
  • Docs page key box renamed from "DefiLlama Pro API Key" to "DefiLlama API Key (API plan)", and it says the key gives the API plan's higher rate limits.
  • The pro spec now lists tags and operations in the free view's order, so adding or removing a key on the docs page no longer reshuffles the sidebar (all 23 sections and 136 shared operations keep their position). Only order and five tag declarations changed; every operation is byte-for-byte the same.
  • Code samples on the docs page and in the test-request modal open on curl instead of the JavaScript SDK, so the first example shows the full host and key placement. The modal fix is in RequestCodeExample.vue (it picked the first custom sample and ignored the workspace client, which defaults to curl), with tests. The SDK samples stay in the dropdown.
  • The keyed URL is merged into the 8 free operations that already had a description (a second description key had hidden it on those, including current prices). From Preserve keyed URLs across the API reference #54.
  • Yield paths are /yields/v1/... everywhere, matching the pro spec. From Preserve keyed URLs across the API reference #54.
  • /stablecoins in both specs (and so llms-free.txt) says supply is keyed by pegType (circulating.peggedUSD, circulating.peggedEUR for EURC, and so on) and the USD value is circulating[pegType] * price only when price is a number (it is null for many assets). The generator copies a **Response:** paragraph from an operation description into llms-free.txt.
  • The pro endpoint count in llms.txt is updated (38 to 105). The generator no longer counts the /yields/v1/ twins of the free yield endpoints as pro-only, so 105 pro-only plus 31 twins equals the spec's 136 GET routes.
  • Generator: free yields paths map to /yields/v1/ so they keep their pro twin. llms-free.txt is regenerated (the only other drift is spec-derived Returns: hints). llms.txt and llms-pro.txt are spliced by hand to keep their hand-written content.

Validation

10 user-style requests across TVL, current and historical prices, stablecoins, yields, DEX volume, fees, open interest, a 429 fix and unlocks valued at current prices. The key was given in .env, inline, as "API plan", "paid" or "DefiLlama Pro". Each request ran in a fresh, isolated coding session with three model sizes, with only llms-free.txt as docs. Each shipped script was then run with the key behind a logging proxy, and passes only if every llama.fi request went to pro-api.llama.fi.

docs small medium large total
main 7/10 3/10 3/10 13/30
this PR 10/10 10/10 10/10 30/30

Free users are not affected: the same 10 topics asked with no key anywhere (unlocks swapped for chain TVL, which needs no plan) passed 30/30 on main and 30/30 on this PR. Every script worked on the free hosts and none called pro-api.

On main, every price question (current, historical, unlocks valued at price) went to coins.llama.fi, even in sessions that used pro-api for the rest. The same sessions given the full site, no docs or the live site already used pro-api.

Related

Not covered here

  • defillama.com/docs/api, defillama.com/pro-api/docs and the docs.llama.fi API page live in other repos and could carry the same section.
  • A 429 body from the free hosts that says "have a key? use pro-api.llama.fi/{key}" would catch callers that never read docs.
  • Header auth, once it ships, needs the "not read" lines updated.

Code written from llms-free.txt called the free hosts even when the user
said they had an API key, so paying users hit the free rate limit.

- Add a "Have an API key?" section at the top of llms.txt, llms-free.txt
  and llms-pro.txt: every request goes to pro-api.llama.fi, free hosts never
  read a key, a 429 there means the wrong host, and the $49 Pro plan has no key.
- List the keyed pro-api URL under every free endpoint in llms-free.txt.
- Say the same on the static homepage and in the free spec description.
- Note that header and query keys get "API Key is wrong" from pro-api.
- Rename the docs page key box to "API Key (API plan)".
- Map free yields paths to /yields/v1/ so they keep a pro twin.
run.mjs has headless coding sessions write integrations from the docs with
a real key. grade.mjs runs each shipped script behind a logging proxy and
records which llama.fi hosts it contacts.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Deploying api-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: dbe0489
Status: ✅  Deploy successful!
Preview URL: https://e4c70a25.api-docs-59g.pages.dev
Branch Preview URL: https://claude-fix-agents-use-pro-ap.api-docs-59g.pages.dev

View logs

The docs page without a key shows free operations on their free hosts and
no keyed alternative, so readers with a key copy the free URL. Each free
operation now names its pro-api.llama.fi twin.
The key rule no longer says which subscription includes a key. It only
says that a user with a key, whatever they call their plan, uses
pro-api.llama.fi. The eval scripts move out of this repo.
The three files repeated the same key rules in three sections. They now
share one section with a right and wrong example. It also says fallback
lookups go to pro-api, and links llms.txt and llms-pro.txt by absolute
URL so a saved copy can still reach them.

@alpacai alpacai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix three issues at the reviewed head, e64e5af.

  1. P1 — Duplicate JSON keys suppress the paid URL on eight operations. For example, the two description entries at current prices parse as the second value only. This affects TVL, current and historical prices, coin chart and percentage, closest block, and both Yield operations. Combine the new callout and original description into one field so both reach Scalar and raw-spec consumers.
  2. P2 — The text docs recommend inconsistent Yield paths. The index and Pro table still direct clients to the unversioned URLs, while the generated endpoint listings and Pro spec give /yields/v1/pools and /yields/v1/chart/{pool}. Both pool URLs returned data in a live lookup, so this is a documentation consistency issue. Use the versioned paths in both tables and the shared auth example.
  3. P2 — The key box incorrectly promises no rate limits. The new copy says the paid endpoints are unlimited, but the API plan specifies 1,000 requests per minute. Say that requests use the API plan’s higher rate limits.

treeoflife2 and others added 3 commits November 24, 2026 20:39
Scalar selects the first custom sample unless a default client is configured. curl shows the full URL with host and key placement.
The /stablecoins operation in both specs now says the USD supply is
nested at circulating.peggedUSD and the price is price. The generator
copies a "**Response:**" paragraph from an operation description into
llms-free.txt, so the spec stays the single source.

Also fix the stale pro endpoint count in llms.txt (38 to 107).

@alpacai alpacai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues in the latest handwritten changes need correction.

  1. The stablecoin response note says every asset has USD circulation at circulating.peggedUSD. A live response contained USDC under peggedUSD and EURC under peggedEUR. Scope the hint to USD-pegged assets such as USDC and describe it as circulating supply. Keep the separate price field for USD valuation. Update both OpenAPI descriptions and regenerate the free text.
  2. The new endpoint total double-counts the two mapped Yield v1 operations as both exclusive and free equivalents. The Pro spec contains 136 GET routes, with 31 distinct mapped equivalents and 105 remaining. Derive the exclusive list and count from the same mapping used in the table, or report the total as 136 including 31 mapped equivalents.

The short check confirmed all 31 keyed mappings agree after parsing, the free text regenerates byte for byte, and the Cloudflare preview renders the higher-limit copy with Shell Curl selected.

… twins

circulating holds one key per asset, named after its pegType (peggedUSD,
peggedEUR for EURC, and 28 other currencies), so the hint now says to read
circulating[asset.pegType] and multiply by price for USD.

Pro-only endpoints are now every pro path that is not the twin of a free
endpoint. The /yields/v1/ twins of the deprecated free yields were counted
twice: 105 pro-only plus 31 twins now equals the 136 GET routes.

@alpacai alpacai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The peg-specific field and disjoint endpoint counts both check out. One correction remains in the new USD formula.

Guard the calculation against missing quotes. The response note gives circulating[asset.pegType] * price unconditionally, but the live keyed response included 203 assets with positive circulating supply and price: null. USDX (id 214) was one example. JavaScript multiplies a number by null and returns zero, which reports an unavailable valuation as zero. Say to multiply when price is numeric and otherwise leave USD value unavailable. Update the shared note in the free and Pro specs and regenerate the free text.

The focused recheck passed all 31 keyed mappings, exact free-text regeneration, and coverage of all 136 Pro GET paths with 105 exclusive routes and 31 distinct free equivalents.

203 assets have positive supply and price: null (for example USDX). Multiplying by null gives 0 in JavaScript, which reports a missing quote as a zero valuation. The note now says the USD value is unavailable when price is not a number.
alpacai[bot]
alpacai Bot previously approved these changes Nov 24, 2026

@alpacai alpacai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest stablecoin note limits USD valuation to numeric prices and keeps null quotes unavailable. Both OpenAPI specs and the free text carry the same note. Checked numeric and null examples, all 31 keyed route mappings, exact regeneration of llms-free.txt, and the green live free-API check.

…s its layout

Adding or removing a key on the docs page swaps the free view for the pro
spec. The two listed tags and operations in different orders, so the whole
sidebar reshuffled. The pro spec now declares tags in the free view's order
(free tags first, adding coins, volumes, fees and revenue, perps and bridges)
and lists each tag's free-endpoint twins first, in the free spec's order.

Only order and the five tag declarations change; every operation is
byte-for-byte the same. All 136 shared sidebar entries now keep their
position. The free view still also lists the deprecated free /pools and
/chart/{pool} next to their /yields/v1/ twins.
The test-request modal picked the first custom code sample (the
JavaScript SDK) whenever an operation had one, ignoring the workspace
client, which defaults to shell/curl. It now starts on the workspace
client. Custom samples stay in the dropdown and a picked one sticks.
@treeoflife2
treeoflife2 merged commit e20aa92 into main Nov 24, 2026
2 checks passed
@treeoflife2
treeoflife2 deleted the claude/fix-agents-use-pro-api branch November 24, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant