API Reference

/ai Endpoint

Ask currency questions in plain English, the AI endpoint understands the request and answers using current CurrencyCore reference rates.


GET /v1/ai answers one natural-language question about currency conversion, foreign-exchange (FX) rates, or purchasing-power parity (PPP). It returns a plain text answer and a data array containing the structured results the model used.

The endpoint is HTTP only. The same currency tools are available over MCP, but /v1/ai itself is not an MCP tool.

Endpoint

GET https://api.currency-core.com/v1/ai?q=<question>

Authenticate with either header:

Authorization: Bearer <key>
x-api-key: <key>

The question travels in the URL. Percent-encode it, or use your HTTP client’s query-parameter API. Do not put API keys or secrets in q: query strings can be recorded by proxies and access logs.

Request parameters

ParameterTypeRequiredDescription
qstringYesOne natural-language question. Whitespace is trimmed. Empty or missing returns 400 invalid_input.

Input limits

LimitNativeWith BYOK
q token cap (approximate)200400
Total model input cap (approximate, including system prompt and tool schemas)4,0008,000

The caps are enforced before the model runs. An over-budget request returns 413 invalid_input and is not metered, so it consumes no AI credit and does not count toward the monthly request quota. Growth+ requests include a larger fixed system prompt and tool set; the total cap is adjusted so the documented q cap remains the practical bound.

Response

The current success response has exactly these fields:

{
  "query": "Convert 50 euro to indian rupees",
  "answer": "50 EUR = 5,255.00 INR at the 2026-11-10 reference rate.",
  "data": [
    {
      "from": "EUR",
      "to": "INR",
      "amount": 50,
      "result": 5255,
      "rate": 105.1,
      "pppApplied": false,
      "asOf": "2026-11-10"
    }
  ],
  "toolCalls": 1
}

The numbers above are illustrative. Actual rates depend on the current reference data.

Response fields

FieldTypePresentDescription
querystringAlwaysYour question, trimmed and echoed back.
answerstringAlways on 200Plain text, no Markdown. Usually one sentence for a single conversion or rate, two or three short sentences for a trend, comparison, or report.
dataarrayAlways, may be emptyDynamic array of result objects. Each object is one successful data-tool result. The internal currency-resolution step is not included.
toolCallsnumberAlways on a 200Number of successful billable tool calls behind the answer. Failed calls and the internal currency-resolution step are not counted. On a native answer this is informational; with BYOK active, each tool call is billed as one API request.
byokbooleanOnly when BYOK is active for the organizationtrue when your own provider produced the answer, false when the answer came from CurrencyCore’s providers (a fallback). Omitted entirely when BYOK is not active.

toolCalls equals the number of objects in data on a normal answer. A 200 that asks you to narrow a too-large analysis has data: [] and toolCalls: 0.

Response headers

These headers are sent by the current route:

HeaderMeaning
x-currencycore-ai-byoktrue when your own BYOK provider produced the answer, otherwise false.
x-currencycore-ai-providercurrencycore for native answers, or the BYOK provider id (for example openai).
x-currencycore-ai-attemptsWhich attempt produced the answer, from 1 to 3.
x-currencycore-ai-toolsSame value as toolCalls.
x-currencycore-ai-fasttrue only when the optional deterministic fast path answered the request. It is normally false.
x-currencycore-ai-msServer-side execution time in milliseconds.
Server-Timingai;dur=<milliseconds>.
Cache-Controlno-store, because responses are organization-specific.
VaryAuthorization.

There is no request ID header today. See AI errors for what to include in a support request.

data shapes

data is a dynamic array: each entry is the result of one successful tool call, and different entries can have different shapes. There is no kind discriminator and no top-level outcome field. Detect the shape from its fields.

The 12 current shapes use the same field names and conventions as the REST results where a matching REST endpoint exists:

ShapeRecognizable byReference
ConvertpppApplied, amount, result, rate/convert
Ratesrates map/rates
History analysisresults[] with strengthenedPct and changePct/history/analysis
PPP analysisnumeric from/to years and results[] with startFactor/ppp/analysis
Volatilityresults[] with volatility and observations/volatility
Correlationresults[] with correlation/correlation
Drawdownresults[] with maxDrawdownPct and no crisis/drawdown
Safe haventop-level crisis/safe-haven
Mean reversionresults[] with deviationPct/mean-reversion
Risk adjustedresults[] with riskAdjustedResponse schema
Streaksresults[] with maxStreakYearsResponse schema
Stabilitytop-level bandPctResponse schema

The complete TypeScript definitions, including optional fields, are on AI response schema.

Convert

Returned for a conversion, a single-pair rate lookup (usually with amount: 1), or a PPP-adjusted conversion.

FieldTypeDescription
fromstringSource currency code.
tostringTarget currency code.
amountnumberAmount converted. 1 for a plain pair rate.
resultnumberConverted amount. When PPP is applied, this is the PPP-adjusted amount, not the FX-converted amount.
ratenumberresult divided by amount. Without PPP this is the FX rate in target units per source unit. With PPP it is the implied PPP conversion ratio, not the market FX rate.
pppAppliedbooleantrue when a PPP factor was applied.
asOfstringReference date of the rate, YYYY-MM-DD. This can be earlier than the request date on a weekend or holiday.
fromCountrystring, optionalAlpha-3 country used for the source side when PPP was applied.
toCountrystring, optionalAlpha-3 country used for the target side when PPP was applied.
pppYearnumber, optionalYear of the PPP factors used.
pppSourcestring, optionalSource label for the PPP factors, for example IMF World Economic Outlook.

asOf is a rate reference date, not the time of the request. Rates are central-bank reference rates polled hourly; the underlying fixings are daily, so values normally change once per business day. They are not real-time or executable quotes.

Rates

Returned for a multi-currency list against one base.

FieldTypeDescription
basestringBase currency.
asOfstringReference date of the rates.
ratesobjectMap of currency code to units of that currency per one unit of base.

History analysis

Returned for a trend, comparison, movers ranking, or multi-currency report. Growth+ only.

FieldTypeDescription
basestringCurrency everything is measured against.
fromstringWindow start, YYYY-MM-DD. Defaults to 20 years before to when no window is named.
tostringWindow end, YYYY-MM-DD.
modestringcompare when specific currencies were named, movers when the engine ranked a universe.
resultsarrayOne entry per currency.

Each results[] entry:

FieldTypeDescription
currencystringCurrency code.
startRatenumber or nullRate at the window start, in currency units per one base.
endRatenumber or nullRate at the window end.
changePctnumber or nullPercent change in the quoted rate over the window.
strengthenedPctnumber or nullAppreciation against base. Positive means the currency strengthened. This is the intuitive “who went up” figure.
statsobject, optional{ min, max, avg } over the window. The AI engine does not compute stats for every request, so this field is often absent.
seriesobject, optionalDownsampled trend as a map of period label to average rate.
volatilitynumber or null, optionalAnnualized volatility over the window. Present in compare mode for report-style answers.

changePct and strengthenedPct have opposite signs for a non-USD currency because one measures the quoted rate and the other measures the currency’s strength. Use strengthenedPct for direction.

PPP analysis

Returned for PPP factor changes over time. Growth+ only. from and to are years, not dates.

FieldTypeDescription
fromnumberStart year. Defaults to 10 years before to.
tonumberEnd year.
modestringcompare or movers.
resultsarrayOne entry per country.

Each results[] entry:

FieldTypeDescription
countrystringAlpha-3 country code.
startYearnumberActual start year used.
endYearnumberActual end year used.
startFactornumber or nullPPP factor at the start, in local currency units per international dollar.
endFactornumber or nullPPP factor at the end.
changePctnumber or nullPercent change in the factor. Positive means the factor rose.
projectedbooleantrue when the end value is an IMF projection, not an actual observation.
statsobject, optional{ min, max, avg } over the window.
seriesobject, optionalMap of year to factor.

A PPP factor is a conversion coefficient. A rising factor does not by itself mean purchasing power or living standards improved. See PPP answers below.

Volatility

Growth+ only.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to one year before to.
tostringWindow end.
modestringcompare or ranking.
resultsarrayEntries with currency, volatility (annualized percent, or null), and observations. Lower volatility means more stable.

Correlation

Growth+ only.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to one year before to.
tostringWindow end.
resultsarrayEntries with currency, correlation (number or null), and observations.

Correlation is undefined against the base itself, so ask for correlation between two non-base currencies by naming one as base and the other as the comparand.

Drawdown

Growth+ only.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to one year before to.
tostringWindow end.
resultsarrayEntries with currency and maxDrawdownPct (number or null), plus optional peakDate, troughDate, recoveryDate, and recoveryDays.

maxDrawdownPct is negative or zero for a decline. recoveryDate: null means no recovery within the window.

Safe haven

Growth+ only.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to 2007-01-01, or the earliest date inside the 20-year analytics bound.
tostringWindow end.
crisisstringLabel of the reference crisis used for crisisReturnPct.
resultsarrayEntries with currency, score, volatility, maxDrawdownPct, and crisisReturnPct. Higher score means safer.

Mean reversion

Growth+ only.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to one year before to.
tostringWindow end.
resultsarrayEntries with currency, score, deviationPct, reversionFrequency, and halfLifeDays. Higher score means more mean-reverting.

Risk adjusted

Growth+ only. A Sharpe-like ratio: annualized return divided by annualized volatility.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to 10 years before to.
tostringWindow end.
modestringcompare or ranking.
resultsarrayEntries with currency, annualReturn, volatility, and riskAdjusted. Higher riskAdjusted means more return per unit of risk.

Streaks

Growth+ only. The longest run of consecutive calendar years in which a currency strengthened against base.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to the full available history.
tostringWindow end.
modestringcompare or ranking.
resultsarrayEntries with currency, maxStreakYears, currentStreakYears, streakFrom (year or null), and streakTo (year or null).

Stability

Growth+ only. How far a currency strayed from its starting value.

FieldTypeDescription
basestringBase currency.
fromstringWindow start. Defaults to 5 years before to.
tostringWindow end.
modestringcompare or ranking.
bandPctnumberThe band used, for example 5 for plus or minus 5 percent.
resultsarrayEntries with currency, maxDeviationPct, withinBand, and annualReturn.

Scope

The assistant answers only currency conversion, FX rate, and PPP questions:

  • Conversions. “Convert 1,200 USD to JPY”, “how much is 75 pounds in euros”.
  • Rates. “What is the USD to INR rate today?”, “EUR rates for GBP, JPY, and CAD”.
  • Single-date lookups. “What was the GBP to USD rate on 2015-06-01?” Free organizations are limited to the last 30 days of history; older dates return a normal answer explaining that the date is outside the plan window.
  • PPP conversions and salary equivalence. “I earn GBP 50,000 in London, what is the equivalent in Bangalore?”, “how far does $3,000 go in India versus the US?”. If the amount is missing, the assistant asks for it.
  • Trends, comparisons, and movers (Growth+). “How did EUR perform against USD over the last decade?”, “Which currencies strengthened most against INR since 2015?”, “Compare USD, GBP, EUR, and AED over 20 years”. Named events resolve to documented date windows: COVID-19, the 2008 global financial crisis, Brexit, the European debt crisis, and the dot-com bust.
  • PPP over time (Growth+). “Has India’s PPP changed over the last decade?”, “Compare the PPP of India, Germany, and the US since 2010”.
  • Volatility, correlation, drawdown, safe haven, mean reversion, risk-adjusted return, streaks, and stability (Growth+). “How volatile is EUR/USD?”, “Which currencies are the most stable against USD?”, “How correlated are EUR and GBP?”, “Which currencies had the largest drawdowns?”, “Which is the best safe-haven currency?”, “Which currencies are the most mean-reverting?”, “Which currency pair had the best risk-adjusted return over the last decade?”, “Which currencies strengthened against USD for at least 5 consecutive years?”, “Which currencies stayed within plus or minus 5 percent of USD over the last 5 years?”.

Plan gating

CapabilityPlans
Conversion, single rate, multi-rate, PPP conversion, clarifications, no-data answersEvery plan with AI credits (Free through Enterprise)
Historical trend, comparison, movers, and all analytics questions aboveGrowth and higher
Single-date history older than 30 daysStarter and higher (Free is limited to the last 30 days)
BYOKGrowth and higher
AI credit allowancePer plan: Free 100, Starter 1,000, Growth 5,000, Growth Plus 20,000, Business 50,000, Enterprise custom

On Free and Starter, a trend or analytics question returns a normal 200 whose answer says the capability needs the Growth plan. It is not a 403.

The endpoint can also be turned off per organization in the dashboard, and a platform-wide kill switch can disable it. Either returns 403 forbidden.

PPP answers

PPP is a conversion tool, not a verdict on an economy. The assistant is deliberately conservative:

  • A PPP factor change over time is reported as a plain fact: start factor, end factor, and percent change. It is not described as purchasing power “improving” or “weakening”, because the factor also moves with inflation, relative prices, GDP revisions, and IMF methodology.
  • A cross-country purchasing-power ranking (“which country offers the highest purchasing power?”, “cheapest country to live”) is declined with a normal 200. A bigger PPP factor only means a smaller currency unit, and a real ranking needs cost-of-living data that CurrencyCore does not have. A pairwise PPP comparison between two named places is still answered.

When the data is not available

An in-scope question whose data is unavailable is not an error. It returns a normal 200 with the explanation in answer and data: []:

  • An unsupported currency or asset, including precious metals. Example: “Silver (XAG) is not a supported currency.”
  • No rate for the requested date. Example: “No rate is available for INR on that date.”
  • PPP unavailable for that country or year.
  • A currency used by several countries with no canonical default, for example XCD in the Eastern Caribbean, needs an explicit country for PPP. Example: “Which country should I use for XCD?”
  • An analysis too large to finish within the request deadline. The answer asks you to narrow the window or the number of currencies. It is never a 504.

Credits, BYOK, and limits

AI runs on a separate AI credit pool and does not consume the monthly API request quota on the native path. The exception is BYOK: when your own provider answers, each successful tool call is billed as one API request instead. When both buckets are exhausted, native AI calls are blocked with 429; there is no over-usage billing for AI credits.

SituationAI creditsAPI requests
Native answer, any number of tool calls10
Native 422 unsupported_query10
Native 413 question too long00
Native 503 provider unavailable00
BYOK answer, N successful tool calls0N
BYOK answer with no data tool00
BYOK fails, native fallback answers10
BYOK fails, fallback disabled00

Billing is cumulative across the whole request, not based only on who wrote the final sentence. If any model round ran on CurrencyCore’s providers, the request is treated as native for billing. See BYOK.

The per-minute rate limit is enforced per API key and counts every request, including errors and retries. AI credits are a separate pool from the monthly API request quota; BYOK tool calls are the exception and draw from the request quota.

A native 200 that asks you to narrow a too-large analysis consumes the usual one AI credit. A 200 with no data tools also consumes one AI credit on the native path, because the model was consulted. See AI credits for the full pool and billing rules and BYOK for provider setup.

Latency

  • The orchestration deadline defaults to 15 seconds per attempt.
  • Each provider call has an 8 second timeout by default.
  • The route makes up to 3 attempts for a transient provider unavailability (network error, 429, or 5xx). Deterministic errors and deadline timeouts are not retried.
  • A request that hits the deadline after the model produced usable text can still return a 200.
  • There is no streaming. The whole answer arrives in one JSON response.

There is no documented p50 or p95 latency commitment. Simple conversions are normally faster than multi-currency analytics. Use a client timeout of at least 30 seconds, and 60 seconds for analytical questions, to cover retries.

Privacy and logging

  • The question and the tool results needed to answer it are sent to the model provider. With BYOK, that provider is the one you configured. Without BYOK, it is CurrencyCore’s provider.
  • CurrencyCore stores an AI query log entry per request. It includes the question text (truncated to 2,000 characters), the answer text on success (truncated to 5,000 characters), the tool-call sequence, token counts, model, provider, status, and timing. It is used for usage accounting and debugging.
  • Do not send secrets, credentials, or unnecessary personal data in q.
  • q is treated as a question, and the endpoint does not execute user text as tool instructions. Attempts to change the assistant’s behavior or reveal its instructions are refused. Prompt-injection defenses are not perfect, so do not send secrets or unnecessary personal data.

Failed calls and billing

OutcomeAI credit (native)Retry?
200 normal answer1No
200 timeout answer asking you to narrow the request1Only with a narrower window or fewer currencies
400 missing q0Fix the request
413 question too long0Shorten q
422 out of scope1No, changing the question will not make it in scope
429 no AI credits or rate limited0Wait for Retry-After (per-minute) or the next cycle
503 service unavailable0, the reservation is returnedYes, with exponential backoff
402 billing past due0Clear payment; test keys keep working
403 AI disabled0Re-enable the AI endpoint for the organization

With BYOK, an answer served by your provider costs no AI credit and is billed as one API request per tool call. A failed BYOK call costs nothing. If fallback is enabled and CurrencyCore’s model answers, that answer costs 1 AI credit and reports byok: false in the response and x-currencycore-ai-byok: false in the headers.

Fallback and retry guidance

  • Transient 503: retry with exponential backoff (for example 1s, 2s, 4s, with jitter). The request was not billed.
  • 200 timeout: do not repeat the identical question. Narrow the date range, reduce the number of currencies, or ask for one comparison at a time.
  • 422: do not retry. Rephrase only if you believe the question is within scope; an out-of-scope refusal is deterministic.
  • 429 from the per-minute limiter: wait for the Retry-After header.
  • 429 from exhausted AI credits: wait for the next billing cycle or buy a credit add-on. Retrying immediately will keep failing.
  • BYOK with fallback off: if your provider fails, the request returns an error rather than falling back. Check the provider’s status and key before retrying.

Errors use the standard envelope:

{
  "error": {
    "code": "unsupported_query",
    "message": "This endpoint only answers currency conversion, exchange-rate, and PPP questions."
  }
}
StatusCodeWhenCredits
400invalid_inputq is missing or blank.0
401unauthorizedKey missing, invalid, or revoked.0
402billing_past_dueBilling is past due.0
403forbiddenAI is disabled for the organization or platform-wide.0
413invalid_inputq or total input exceeds the budget. Rejected before the model.0
422unsupported_queryOff-topic question or prompt injection. The model was consulted.1 native
429rate_limitedPer-minute limit, monthly request quota (BYOK tool-call units), or AI credits exhausted.0
500internal_errorUnexpected server error.0
503internal_errorNo provider configured, all providers unreachable, or BYOK required with fallback off but unusable.0

See AI errors for retry guidance, latency budgets, and the support checklist.

Out of scope

The endpoint does not do any of the following:

  • Commodities, precious metals, stocks, indices, crypto, interest rates, or inflation and CPI.
  • Forecasts, price predictions, trading signals, or financial advice.
  • Web browsing, news, or live event lookup.
  • Conversation memory. Every request is independent and stateless.
  • Streaming responses.
  • General-purpose chat or non-currency tasks.
  • Arbitrary code execution or file handling.

A related financial topic gets a specific one-line refusal in answer when it is in scope enough to explain, or 422 unsupported_query when it is off-topic.

What the response does not include yet

The current response is deliberately small. Do not build against fields that are not listed here.

Not included todayCurrent workaround
outcome or status field in the bodyUse the HTTP status, and inspect answer plus data for 200 non-answers.
kind discriminator on data entriesDetect the shape from its fields. See AI response schema.
Citations or per-number source linksTreat data as canonical and verify against the matching REST endpoint. See AI grounding.
Tool names, tool inputs, or a tracetoolCalls gives only the count. Response headers expose BYOK routing and timing, not tool names.
Token usage blockNot returned. Token counts appear in server-side logs only.
Model or provider name in the bodyUse x-currencycore-ai-provider and x-currencycore-ai-byok headers. Native answers report only currencycore.
Request IDNot returned. Capture the time, query, and response headers for support.
Error code on a 200 non-answerInspect answer and data. A clarifying question, refusal, or narrowing request is still 200.

Examples

curl -G https://api.currency-core.com/v1/ai \
  --data-urlencode "q=Convert 50 euro to indian rupees" \
  -H "Authorization: Bearer $CURRENCYCORE_KEY"