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
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | Yes | One natural-language question. Whitespace is trimmed. Empty or missing returns 400 invalid_input. |
Input limits
| Limit | Native | With BYOK |
|---|---|---|
q token cap (approximate) | 200 | 400 |
| Total model input cap (approximate, including system prompt and tool schemas) | 4,000 | 8,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
| Field | Type | Present | Description |
|---|---|---|---|
query | string | Always | Your question, trimmed and echoed back. |
answer | string | Always on 200 | Plain text, no Markdown. Usually one sentence for a single conversion or rate, two or three short sentences for a trend, comparison, or report. |
data | array | Always, may be empty | Dynamic array of result objects. Each object is one successful data-tool result. The internal currency-resolution step is not included. |
toolCalls | number | Always on a 200 | Number 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. |
byok | boolean | Only when BYOK is active for the organization | true 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:
| Header | Meaning |
|---|---|
x-currencycore-ai-byok | true when your own BYOK provider produced the answer, otherwise false. |
x-currencycore-ai-provider | currencycore for native answers, or the BYOK provider id (for example openai). |
x-currencycore-ai-attempts | Which attempt produced the answer, from 1 to 3. |
x-currencycore-ai-tools | Same value as toolCalls. |
x-currencycore-ai-fast | true only when the optional deterministic fast path answered the request. It is normally false. |
x-currencycore-ai-ms | Server-side execution time in milliseconds. |
Server-Timing | ai;dur=<milliseconds>. |
Cache-Control | no-store, because responses are organization-specific. |
Vary | Authorization. |
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:
| Shape | Recognizable by | Reference |
|---|---|---|
| Convert | pppApplied, amount, result, rate | /convert |
| Rates | rates map | /rates |
| History analysis | results[] with strengthenedPct and changePct | /history/analysis |
| PPP analysis | numeric from/to years and results[] with startFactor | /ppp/analysis |
| Volatility | results[] with volatility and observations | /volatility |
| Correlation | results[] with correlation | /correlation |
| Drawdown | results[] with maxDrawdownPct and no crisis | /drawdown |
| Safe haven | top-level crisis | /safe-haven |
| Mean reversion | results[] with deviationPct | /mean-reversion |
| Risk adjusted | results[] with riskAdjusted | Response schema |
| Streaks | results[] with maxStreakYears | Response schema |
| Stability | top-level bandPct | Response 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.
| Field | Type | Description |
|---|---|---|
from | string | Source currency code. |
to | string | Target currency code. |
amount | number | Amount converted. 1 for a plain pair rate. |
result | number | Converted amount. When PPP is applied, this is the PPP-adjusted amount, not the FX-converted amount. |
rate | number | result 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. |
pppApplied | boolean | true when a PPP factor was applied. |
asOf | string | Reference date of the rate, YYYY-MM-DD. This can be earlier than the request date on a weekend or holiday. |
fromCountry | string, optional | Alpha-3 country used for the source side when PPP was applied. |
toCountry | string, optional | Alpha-3 country used for the target side when PPP was applied. |
pppYear | number, optional | Year of the PPP factors used. |
pppSource | string, optional | Source 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.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
asOf | string | Reference date of the rates. |
rates | object | Map 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.
| Field | Type | Description |
|---|---|---|
base | string | Currency everything is measured against. |
from | string | Window start, YYYY-MM-DD. Defaults to 20 years before to when no window is named. |
to | string | Window end, YYYY-MM-DD. |
mode | string | compare when specific currencies were named, movers when the engine ranked a universe. |
results | array | One entry per currency. |
Each results[] entry:
| Field | Type | Description |
|---|---|---|
currency | string | Currency code. |
startRate | number or null | Rate at the window start, in currency units per one base. |
endRate | number or null | Rate at the window end. |
changePct | number or null | Percent change in the quoted rate over the window. |
strengthenedPct | number or null | Appreciation against base. Positive means the currency strengthened. This is the intuitive “who went up” figure. |
stats | object, optional | { min, max, avg } over the window. The AI engine does not compute stats for every request, so this field is often absent. |
series | object, optional | Downsampled trend as a map of period label to average rate. |
volatility | number or null, optional | Annualized 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.
| Field | Type | Description |
|---|---|---|
from | number | Start year. Defaults to 10 years before to. |
to | number | End year. |
mode | string | compare or movers. |
results | array | One entry per country. |
Each results[] entry:
| Field | Type | Description |
|---|---|---|
country | string | Alpha-3 country code. |
startYear | number | Actual start year used. |
endYear | number | Actual end year used. |
startFactor | number or null | PPP factor at the start, in local currency units per international dollar. |
endFactor | number or null | PPP factor at the end. |
changePct | number or null | Percent change in the factor. Positive means the factor rose. |
projected | boolean | true when the end value is an IMF projection, not an actual observation. |
stats | object, optional | { min, max, avg } over the window. |
series | object, optional | Map 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.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to one year before to. |
to | string | Window end. |
mode | string | compare or ranking. |
results | array | Entries with currency, volatility (annualized percent, or null), and observations. Lower volatility means more stable. |
Correlation
Growth+ only.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to one year before to. |
to | string | Window end. |
results | array | Entries 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.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to one year before to. |
to | string | Window end. |
results | array | Entries 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.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to 2007-01-01, or the earliest date inside the 20-year analytics bound. |
to | string | Window end. |
crisis | string | Label of the reference crisis used for crisisReturnPct. |
results | array | Entries with currency, score, volatility, maxDrawdownPct, and crisisReturnPct. Higher score means safer. |
Mean reversion
Growth+ only.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to one year before to. |
to | string | Window end. |
results | array | Entries 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.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to 10 years before to. |
to | string | Window end. |
mode | string | compare or ranking. |
results | array | Entries 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.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to the full available history. |
to | string | Window end. |
mode | string | compare or ranking. |
results | array | Entries 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.
| Field | Type | Description |
|---|---|---|
base | string | Base currency. |
from | string | Window start. Defaults to 5 years before to. |
to | string | Window end. |
mode | string | compare or ranking. |
bandPct | number | The band used, for example 5 for plus or minus 5 percent. |
results | array | Entries 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
| Capability | Plans |
|---|---|
| Conversion, single rate, multi-rate, PPP conversion, clarifications, no-data answers | Every plan with AI credits (Free through Enterprise) |
| Historical trend, comparison, movers, and all analytics questions above | Growth and higher |
| Single-date history older than 30 days | Starter and higher (Free is limited to the last 30 days) |
| BYOK | Growth and higher |
| AI credit allowance | Per 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.
| Situation | AI credits | API requests |
|---|---|---|
| Native answer, any number of tool calls | 1 | 0 |
Native 422 unsupported_query | 1 | 0 |
Native 413 question too long | 0 | 0 |
Native 503 provider unavailable | 0 | 0 |
| BYOK answer, N successful tool calls | 0 | N |
| BYOK answer with no data tool | 0 | 0 |
| BYOK fails, native fallback answers | 1 | 0 |
| BYOK fails, fallback disabled | 0 | 0 |
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. qis 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
| Outcome | AI credit (native) | Retry? |
|---|---|---|
200 normal answer | 1 | No |
200 timeout answer asking you to narrow the request | 1 | Only with a narrower window or fewer currencies |
400 missing q | 0 | Fix the request |
413 question too long | 0 | Shorten q |
422 out of scope | 1 | No, changing the question will not make it in scope |
429 no AI credits or rate limited | 0 | Wait for Retry-After (per-minute) or the next cycle |
503 service unavailable | 0, the reservation is returned | Yes, with exponential backoff |
402 billing past due | 0 | Clear payment; test keys keep working |
403 AI disabled | 0 | Re-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. 200timeout: 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.429from the per-minute limiter: wait for theRetry-Afterheader.429from 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."
}
}
| Status | Code | When | Credits |
|---|---|---|---|
400 | invalid_input | q is missing or blank. | 0 |
401 | unauthorized | Key missing, invalid, or revoked. | 0 |
402 | billing_past_due | Billing is past due. | 0 |
403 | forbidden | AI is disabled for the organization or platform-wide. | 0 |
413 | invalid_input | q or total input exceeds the budget. Rejected before the model. | 0 |
422 | unsupported_query | Off-topic question or prompt injection. The model was consulted. | 1 native |
429 | rate_limited | Per-minute limit, monthly request quota (BYOK tool-call units), or AI credits exhausted. | 0 |
500 | internal_error | Unexpected server error. | 0 |
503 | internal_error | No 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 today | Current workaround |
|---|---|
outcome or status field in the body | Use the HTTP status, and inspect answer plus data for 200 non-answers. |
kind discriminator on data entries | Detect the shape from its fields. See AI response schema. |
| Citations or per-number source links | Treat data as canonical and verify against the matching REST endpoint. See AI grounding. |
| Tool names, tool inputs, or a trace | toolCalls gives only the count. Response headers expose BYOK routing and timing, not tool names. |
| Token usage block | Not returned. Token counts appear in server-side logs only. |
| Model or provider name in the body | Use x-currencycore-ai-provider and x-currencycore-ai-byok headers. Native answers report only currencycore. |
| Request ID | Not returned. Capture the time, query, and response headers for support. |
Error code on a 200 non-answer | Inspect answer and data. A clarifying question, refusal, or narrowing request is still 200. |
Related
- AI quickstart
- AI prompt guide
- AI response schema
- AI grounding and verification
- AI errors
- AI credits
- BYOK
Examples
curl -G https://api.currency-core.com/v1/ai \
--data-urlencode "q=Convert 50 euro to indian rupees" \
-H "Authorization: Bearer $CURRENCYCORE_KEY"const url = new URL("https://api.currency-core.com/v1/ai");
url.searchParams.set("q", "Convert 50 euro to indian rupees");
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.CURRENCYCORE_KEY}` },
});
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error?.code}`);
console.log(body.answer);
console.log(body.data[0]?.result);import os
import requests
res = requests.get(
"https://api.currency-core.com/v1/ai",
params={"q": "Convert 50 euro to indian rupees"},
headers={"Authorization": f"Bearer {os.environ['CURRENCYCORE_KEY']}"},
timeout=30,
)
res.raise_for_status()
body = res.json()
print(body["answer"])
print(body["data"][0]["result"])