Repository navigation
docs(llms): send key holders to pro-api for every request - #53
Conversation
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.
Deploying api-docs with
|
| 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 |
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.
There was a problem hiding this comment.
Please fix three issues at the reviewed head, e64e5af.
- P1 — Duplicate JSON keys suppress the paid URL on eight operations. For example, the two
descriptionentries 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. - 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/poolsand/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. - 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.
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).
There was a problem hiding this comment.
Two issues in the latest handwritten changes need correction.
- The stablecoin response note says every asset has USD circulation at
circulating.peggedUSD. A live response contained USDC underpeggedUSDand EURC underpeggedEUR. Scope the hint to USD-pegged assets such as USDC and describe it as circulating supply. Keep the separatepricefield for USD valuation. Update both OpenAPI descriptions and regenerate the free text. - 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Problem
Paying users reported rate limits with barely any usage. Code written from
llms-free.txtcalledapi.llama.fi,coins.llama.fi,stablecoins.llama.fiandyields.llama.fieven when the user said they had a key. Those hosts never read a key, so the requests were free tier.Changes
llms.txt,llms-free.txtandllms-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.txtlists 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}.defillama-openapi-free.jsonnow has a description naming its keyed pro-api URL, so readers of the page and of the raw spec see it too.?apikey=keys are still not read by pro-api: all 10 header formats I tried (Authorization: Bearer, rawAuthorization,x-api-key,apikeyand others) return500 {"error":"API Key is wrong"}with a valid key. The docs quote that error so it is not read as a bad key.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.descriptionkey had hidden it on those, including current prices). From Preserve keyed URLs across the API reference #54./yields/v1/...everywhere, matching the pro spec. From Preserve keyed URLs across the API reference #54./stablecoinsin both specs (and sollms-free.txt) says supply is keyed bypegType(circulating.peggedUSD,circulating.peggedEURfor EURC, and so on) and the USD value iscirculating[pegType] * priceonly whenpriceis a number (it isnullfor many assets). The generator copies a**Response:**paragraph from an operation description intollms-free.txt.llms.txtis 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./yields/v1/so they keep their pro twin.llms-free.txtis regenerated (the only other drift is spec-derivedReturns:hints).llms.txtandllms-pro.txtare 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 onlyllms-free.txtas 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.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