Install the MarginDash SDK for your language.
npm install ai-cost-calc
TypeScript SDK reference: npmjs.com/package/ai-cost-calc
import { AiCostCalc } from "ai-cost-calc";
const md = new AiCostCalc({ apiKey: "YOUR_API_KEY_HERE" }); // Get from Settings page
const response = await md.guardedCall({
customerId: String(user.id),
eventType: "summarize",
}, () => providerCall());
// No prompts or responses ever leave your servers
md.addUsage({
model: response.model,
inputTokens: response.usage?.prompt_tokens,
outputTokens: response.usage?.completion_tokens,
});
md.track({
customerId: String(user.id), // "8291" (must be a string)
eventType: "summarize",
revenueAmountInCents: 500,
});
// Events are flushed automatically in the background.
// Before your process exits:
await md.shutdown();
Privacy first: Only the model name and token counts are sent to MarginDash — no request or response content ever leaves your infrastructure. Pass model and token counts via addUsage(), and MarginDash calculates cost from live pricing data. For agent sessions with multiple AI calls, call addUsage() once per call, then track() once to attach them all.
Click a vendor to see valid slugs for the model field. You can also fetch this list programmatically via GET /api/v1/models.
ai21/jamba-large-1.7
aion-labs/aion-1.0
aion-labs/aion-1.0-mini
aion-labs/aion-2.0
aion-labs/aion-rp-llama-3.1-8b
alfredpros/codellama-7b-instruct-solidity
alibaba/tongyi-deepresearch-30b-a3b
allenai/molmo-2-8b
allenai/olmo-2-0325-32b-instruct
allenai/olmo-3.1-32b-instruct
allenai/olmo-3.1-32b-think
allenai/olmo-3-32b-think
allenai/olmo-3-7b-instruct
allenai/olmo-3-7b-think
alpindale/goliath-120b
amazon/nova-2-lite-v1
amazon/nova-lite-v1
amazon/nova-micro-v1
amazon/nova-premier-v1
amazon/nova-pro-v1
anthracite-org/magnum-v4-72b
anthropic/claude-3.5-haiku
anthropic/claude-3.5-sonnet
anthropic/claude-3.7-sonnet
anthropic/claude-3.7-sonnet:thinking
anthropic/claude-3-haiku
anthropic/claude-haiku-4.5
anthropic/claude-opus-4
anthropic/claude-opus-4.1
anthropic/claude-opus-4.5
anthropic/claude-opus-4.6
anthropic/claude-opus-4.6-fast
anthropic/claude-sonnet-4
anthropic/claude-sonnet-4.5
anthropic/claude-sonnet-4.6
arcee-ai/coder-large
arcee-ai/maestro-reasoning
arcee-ai/spotlight
arcee-ai/trinity-large-preview:free
arcee-ai/trinity-large-thinking
arcee-ai/trinity-mini
arcee-ai/trinity-mini:free
arcee-ai/virtuoso-large
baidu/ernie-4.5-21b-a3b
baidu/ernie-4.5-21b-a3b-thinking
baidu/ernie-4.5-300b-a47b
baidu/ernie-4.5-vl-28b-a3b
baidu/ernie-4.5-vl-424b-a47b
bytedance/ui-tars-1.5-7b
bytedance-seed/seed-1.6
bytedance-seed/seed-1.6-flash
bytedance-seed/seed-2.0-lite
bytedance-seed/seed-2.0-mini
cognitivecomputations/dolphin-mistral-24b-venice-edition:free
cohere/command-a
cohere/command-r-08-2024
cohere/command-r-plus-08-2024
cohere/command-r7b-12-2024
deepcogito/cogito-v2.1-671b
deepseek/deepseek-chat
deepseek/deepseek-chat-v3-0324
deepseek/deepseek-chat-v3.1
deepseek/deepseek-v3.1-terminus
deepseek/deepseek-v3.1-terminus:exacto
deepseek/deepseek-v3.2
deepseek/deepseek-v3.2-exp
deepseek/deepseek-v3.2-speciale
deepseek/deepseek-r1
deepseek/deepseek-r1-0528
deepseek/deepseek-r1-distill-llama-70b
deepseek/deepseek-r1-distill-qwen-32b
eleutherai/llemma_7b
essentialai/rnj-1-instruct
google/gemini-2.0-flash-001
google/gemini-2.0-flash-lite-001
google/gemini-2.5-flash
google/gemini-2.5-flash-lite
google/gemini-2.5-flash-lite-preview-09-2025
google/gemini-2.5-pro
google/gemini-2.5-pro-preview-05-06
google/gemini-2.5-pro-preview
google/gemini-3.1-flash-lite-preview
google/gemini-3.1-pro-preview
google/gemini-3.1-pro-preview-customtools
google/gemini-3-flash-preview
google/gemini-3-pro-preview
google/gemma-2-27b-it
google/gemma-2-9b-it
google/gemma-3-12b-it
google/gemma-3-12b-it:free
google/gemma-3-27b-it
google/gemma-3-27b-it:free
google/gemma-3-4b-it
google/gemma-3-4b-it:free
google/gemma-3n-e2b-it:free
google/gemma-3n-e4b-it
google/gemma-3n-e4b-it:free
google/gemma-4-26b-a4b-it
google/gemma-4-26b-a4b-it:free
google/gemma-4-31b-it
google/gemma-4-31b-it:free
google/lyria-3-clip-preview
google/lyria-3-pro-preview
google/gemini-3.1-flash-image-preview
google/gemini-2.5-flash-image
google/gemini-3-pro-image-preview
gryphe/mythomax-l2-13b
ibm-granite/granite-4.0-h-micro
inception/mercury
inception/mercury-2
inception/mercury-coder
inflection/inflection-3-pi
inflection/inflection-3-productivity
kwaipilot/kat-coder-pro
kwaipilot/kat-coder-pro-v2
liquid/lfm-2-24b-a2b
liquid/lfm-2.2-6b
liquid/lfm-2.5-1.2b-instruct:free
liquid/lfm-2.5-1.2b-thinking:free
liquid/lfm2-8b-a1b
mancer/weaver
meituan/longcat-flash-chat
meta-llama/llama-guard-3-8b
meta-llama/llama-3.1-405b
meta-llama/llama-3.1-405b-instruct
meta-llama/llama-3.1-70b-instruct
meta-llama/llama-3.1-8b-instruct
meta-llama/llama-3.2-11b-vision-instruct
meta-llama/llama-3.2-1b-instruct
meta-llama/llama-3.2-3b-instruct
meta-llama/llama-3.2-3b-instruct:free
meta-llama/llama-3.3-70b-instruct
meta-llama/llama-3.3-70b-instruct:free
meta-llama/llama-3-70b-instruct
meta-llama/llama-3-8b-instruct
meta-llama/llama-4-maverick
meta-llama/llama-4-scout
meta-llama/llama-guard-2-8b
meta-llama/llama-guard-4-12b
microsoft/phi-4
microsoft/wizardlm-2-8x22b
minimax/minimax-01
minimax/minimax-m1
minimax/minimax-m2
minimax/minimax-m2.1
minimax/minimax-m2.5
minimax/minimax-m2.5:free
minimax/minimax-m2.7
minimax/minimax-m2-her
mistralai/codestral-2508
mistralai/devstral-2512
mistralai/devstral-medium
mistralai/devstral-small
mistralai/mistral-large
mistralai/mistral-large-2407
mistralai/mistral-large-2411
mistralai/ministral-14b-2512
mistralai/ministral-3b-2512
mistralai/ministral-8b-2512
mistralai/mistral-7b-instruct-v0.1
mistralai/mistral-large-2512
mistralai/mistral-medium-3
mistralai/mistral-medium-3.1
mistralai/mistral-nemo
mistralai/mistral-small-24b-instruct-2501
mistralai/mistral-small-3.1-24b-instruct
mistralai/mistral-small-3.1-24b-instruct:free
mistralai/mistral-small-3.2-24b-instruct
mistralai/mistral-small-2603
mistralai/mistral-small-creative
mistralai/mixtral-8x22b-instruct
mistralai/mixtral-8x7b-instruct
mistralai/pixtral-12b
mistralai/pixtral-large-2411
mistralai/mistral-saba
mistralai/voxtral-small-24b-2507
moonshotai/kimi-k2
moonshotai/kimi-k2-0905
moonshotai/kimi-k2-0905:exacto
moonshotai/kimi-k2.5
moonshotai/kimi-k2-thinking
morph/morph-v3-fast
morph/morph-v3-large
neversleep/llama-3.1-lumimaid-8b
neversleep/noromaid-20b
nex-agi/deepseek-v3.1-nex-n1
nousresearch/hermes-3-llama-3.1-405b
nousresearch/hermes-3-llama-3.1-405b:free
nousresearch/hermes-3-llama-3.1-70b
nousresearch/hermes-4-405b
nousresearch/hermes-4-70b
nousresearch/hermes-2-pro-llama-3-8b
nvidia/llama-3.1-nemotron-70b-instruct
nvidia/llama-3.1-nemotron-ultra-253b-v1
nvidia/llama-3.3-nemotron-super-49b-v1.5
nvidia/nemotron-3-nano-30b-a3b
nvidia/nemotron-3-nano-30b-a3b:free
nvidia/nemotron-3-super-120b-a12b
nvidia/nemotron-3-super-120b-a12b:free
nvidia/nemotron-nano-12b-v2-vl
nvidia/nemotron-nano-12b-v2-vl:free
nvidia/nemotron-nano-9b-v2
nvidia/nemotron-nano-9b-v2:free
openai/gpt-3.5-turbo
openai/gpt-3.5-turbo-16k
openai/gpt-3.5-turbo-instruct
openai/gpt-3.5-turbo-0613
openai/gpt-4
openai/gpt-4.1
openai/gpt-4.1-mini
openai/gpt-4.1-nano
openai/gpt-4o
openai/gpt-4o-2024-05-13
openai/gpt-4o-2024-08-06
openai/gpt-4o-2024-11-20
openai/gpt-4o-audio-preview
openai/gpt-4o:extended
openai/gpt-4-0314
openai/gpt-4o-mini
openai/gpt-4o-mini-2024-07-18
openai/gpt-4o-mini-search-preview
openai/gpt-4o-search-preview
openai/gpt-4-turbo
openai/gpt-4-1106-preview
openai/gpt-4-turbo-preview
openai/gpt-5
openai/gpt-5.1
openai/gpt-5.1-chat
openai/gpt-5.1-codex
openai/gpt-5.1-codex-max
openai/gpt-5.1-codex-mini
openai/gpt-5.2
openai/gpt-5.2-chat
openai/gpt-5.2-codex
openai/gpt-5.2-pro
openai/gpt-5.3-chat
openai/gpt-5.3-codex
openai/gpt-5.4
openai/gpt-5.4-mini
openai/gpt-5.4-nano
openai/gpt-5.4-pro
openai/gpt-5-chat
openai/gpt-5-codex
openai/gpt-5-image
openai/gpt-5-image-mini
openai/gpt-5-mini
openai/gpt-5-nano
openai/gpt-5-pro
openai/gpt-audio
openai/gpt-audio-mini
openai/gpt-oss-120b
openai/gpt-oss-120b:exacto
openai/gpt-oss-120b:free
openai/gpt-oss-20b
openai/gpt-oss-20b:free
openai/gpt-oss-safeguard-20b
openai/o1
openai/o1-pro
openai/o3
openai/o3-deep-research
openai/o3-mini
openai/o3-mini-high
openai/o3-pro
openai/o4-mini
openai/o4-mini-deep-research
openai/o4-mini-high
openrouter/free
openrouter/healer-alpha
openrouter/hunter-alpha
perplexity/sonar
perplexity/sonar-deep-research
perplexity/sonar-pro
perplexity/sonar-pro-search
perplexity/sonar-reasoning-pro
prime-intellect/intellect-3
qwen/qwen-2.5-72b-instruct
qwen/qwen-2.5-coder-32b-instruct
qwen/qwen-2.5-7b-instruct
qwen/qwen2.5-coder-7b-instruct
qwen/qwen2.5-vl-32b-instruct
qwen/qwen2.5-vl-72b-instruct
qwen/qwen-2.5-vl-7b-instruct
qwen/qwen3-14b
qwen/qwen3-235b-a22b
qwen/qwen3-235b-a22b-2507
qwen/qwen3-235b-a22b-thinking-2507
qwen/qwen3-30b-a3b
qwen/qwen3-30b-a3b-instruct-2507
qwen/qwen3-30b-a3b-thinking-2507
qwen/qwen3-32b
qwen/qwen3-4b:free
qwen/qwen3.5-122b-a10b
qwen/qwen3.5-27b
qwen/qwen3.5-35b-a3b
qwen/qwen3.5-397b-a17b
qwen/qwen3.5-9b
qwen/qwen3.5-flash-02-23
qwen/qwen3.5-plus-02-15
qwen/qwen3.6-plus
qwen/qwen3.6-plus:free
qwen/qwen3.6-plus-preview:free
qwen/qwen3-8b
qwen/qwen3-coder-30b-a3b-instruct
qwen/qwen3-coder
qwen/qwen3-coder:exacto
qwen/qwen3-coder:free
qwen/qwen3-coder-flash
qwen/qwen3-coder-next
qwen/qwen3-coder-plus
qwen/qwen3-max
qwen/qwen3-max-thinking
qwen/qwen3-next-80b-a3b-instruct
qwen/qwen3-next-80b-a3b-instruct:free
qwen/qwen3-next-80b-a3b-thinking
qwen/qwen3-vl-235b-a22b-instruct
qwen/qwen3-vl-235b-a22b-thinking
qwen/qwen3-vl-30b-a3b-instruct
qwen/qwen3-vl-30b-a3b-thinking
qwen/qwen3-vl-32b-instruct
qwen/qwen3-vl-8b-instruct
qwen/qwen3-vl-8b-thinking
qwen/qwen-max
qwen/qwen-plus
qwen/qwen-plus-2025-07-28
qwen/qwen-plus-2025-07-28:thinking
qwen/qwen-turbo
qwen/qwen-vl-max
qwen/qwen-vl-plus
qwen/qwq-32b
raifle/sorcererlm-8x22b
reka/reka-edge
rekaai/reka-edge
rekaai/reka-flash-3
relace/relace-apply-3
relace/relace-search
sao10k/l3.1-70b-hanami-x1
sao10k/l3.1-euryale-70b
sao10k/l3.3-euryale-70b
sao10k/l3-lunaris-8b
sao10k/l3-euryale-70b
stepfun/step-3.5-flash
stepfun/step-3.5-flash:free
switchpoint/router
tencent/hunyuan-a13b-instruct
thedrummer/cydonia-24b-v4.1
thedrummer/rocinante-12b
thedrummer/skyfall-36b-v2
thedrummer/unslopnemo-12b
tngtech/deepseek-r1t2-chimera
undi95/remm-slerp-l2-13b
upstage/solar-pro-3
writer/palmyra-x5
x-ai/grok-3
x-ai/grok-3-beta
x-ai/grok-3-mini
x-ai/grok-3-mini-beta
x-ai/grok-4
x-ai/grok-4.1-fast
x-ai/grok-4.20
x-ai/grok-4.20-beta
x-ai/grok-4.20-multi-agent
x-ai/grok-4.20-multi-agent-beta
x-ai/grok-4-fast
x-ai/grok-code-fast-1
xiaomi/mimo-v2-flash
xiaomi/mimo-v2-omni
xiaomi/mimo-v2-pro
z-ai/glm-4-32b
z-ai/glm-4.5
z-ai/glm-4.5-air
z-ai/glm-4.5-air:free
z-ai/glm-4.5v
z-ai/glm-4.6
z-ai/glm-4.6:exacto
z-ai/glm-4.6v
z-ai/glm-4.7
z-ai/glm-4.7-flash
z-ai/glm-5
z-ai/glm-5.1
z-ai/glm-5-turbo
z-ai/glm-5v-turbo
Install the MarginDash SDK for your language.
pip install ai-cost-calc
Python SDK reference: pypi.org/project/ai-cost-calc
from ai_cost_calc import AiCostCalc
md = AiCostCalc(api_key="YOUR_API_KEY_HERE") # Get from Settings page
response = md.guarded_call(
customer_id=str(user.id),
event_type="summarize",
call=lambda: provider_call(),
)
# No prompts or responses ever leave your servers
md.add_usage(
model=response.model,
input_tokens=response.usage.prompt_tokens,
output_tokens=response.usage.completion_tokens,
)
md.track(
customer_id=str(user.id), # "8291" (must be a string)
event_type="summarize",
revenue_amount_in_cents=500,
)
# Events are flushed automatically in the background.
# Before your process exits:
md.shutdown()
Privacy first: Only the model name and token counts are sent to MarginDash — no request or response content ever leaves your infrastructure. Pass model and token counts via add_usage(), and MarginDash calculates cost from live pricing data. For agent sessions with multiple AI calls, call add_usage() once per call, then track() once to attach them all.
Click a vendor to see valid slugs for the model field. You can also fetch this list programmatically via GET /api/v1/models.
ai21/jamba-large-1.7
aion-labs/aion-1.0
aion-labs/aion-1.0-mini
aion-labs/aion-2.0
aion-labs/aion-rp-llama-3.1-8b
alfredpros/codellama-7b-instruct-solidity
alibaba/tongyi-deepresearch-30b-a3b
allenai/molmo-2-8b
allenai/olmo-2-0325-32b-instruct
allenai/olmo-3.1-32b-instruct
allenai/olmo-3.1-32b-think
allenai/olmo-3-32b-think
allenai/olmo-3-7b-instruct
allenai/olmo-3-7b-think
alpindale/goliath-120b
amazon/nova-2-lite-v1
amazon/nova-lite-v1
amazon/nova-micro-v1
amazon/nova-premier-v1
amazon/nova-pro-v1
anthracite-org/magnum-v4-72b
anthropic/claude-3.5-haiku
anthropic/claude-3.5-sonnet
anthropic/claude-3.7-sonnet
anthropic/claude-3.7-sonnet:thinking
anthropic/claude-3-haiku
anthropic/claude-haiku-4.5
anthropic/claude-opus-4
anthropic/claude-opus-4.1
anthropic/claude-opus-4.5
anthropic/claude-opus-4.6
anthropic/claude-opus-4.6-fast
anthropic/claude-sonnet-4
anthropic/claude-sonnet-4.5
anthropic/claude-sonnet-4.6
arcee-ai/coder-large
arcee-ai/maestro-reasoning
arcee-ai/spotlight
arcee-ai/trinity-large-preview:free
arcee-ai/trinity-large-thinking
arcee-ai/trinity-mini
arcee-ai/trinity-mini:free
arcee-ai/virtuoso-large
baidu/ernie-4.5-21b-a3b
baidu/ernie-4.5-21b-a3b-thinking
baidu/ernie-4.5-300b-a47b
baidu/ernie-4.5-vl-28b-a3b
baidu/ernie-4.5-vl-424b-a47b
bytedance/ui-tars-1.5-7b
bytedance-seed/seed-1.6
bytedance-seed/seed-1.6-flash
bytedance-seed/seed-2.0-lite
bytedance-seed/seed-2.0-mini
cognitivecomputations/dolphin-mistral-24b-venice-edition:free
cohere/command-a
cohere/command-r-08-2024
cohere/command-r-plus-08-2024
cohere/command-r7b-12-2024
deepcogito/cogito-v2.1-671b
deepseek/deepseek-chat
deepseek/deepseek-chat-v3-0324
deepseek/deepseek-chat-v3.1
deepseek/deepseek-v3.1-terminus
deepseek/deepseek-v3.1-terminus:exacto
deepseek/deepseek-v3.2
deepseek/deepseek-v3.2-exp
deepseek/deepseek-v3.2-speciale
deepseek/deepseek-r1
deepseek/deepseek-r1-0528
deepseek/deepseek-r1-distill-llama-70b
deepseek/deepseek-r1-distill-qwen-32b
eleutherai/llemma_7b
essentialai/rnj-1-instruct
google/gemini-2.0-flash-001
google/gemini-2.0-flash-lite-001
google/gemini-2.5-flash
google/gemini-2.5-flash-lite
google/gemini-2.5-flash-lite-preview-09-2025
google/gemini-2.5-pro
google/gemini-2.5-pro-preview-05-06
google/gemini-2.5-pro-preview
google/gemini-3.1-flash-lite-preview
google/gemini-3.1-pro-preview
google/gemini-3.1-pro-preview-customtools
google/gemini-3-flash-preview
google/gemini-3-pro-preview
google/gemma-2-27b-it
google/gemma-2-9b-it
google/gemma-3-12b-it
google/gemma-3-12b-it:free
google/gemma-3-27b-it
google/gemma-3-27b-it:free
google/gemma-3-4b-it
google/gemma-3-4b-it:free
google/gemma-3n-e2b-it:free
google/gemma-3n-e4b-it
google/gemma-3n-e4b-it:free
google/gemma-4-26b-a4b-it
google/gemma-4-26b-a4b-it:free
google/gemma-4-31b-it
google/gemma-4-31b-it:free
google/lyria-3-clip-preview
google/lyria-3-pro-preview
google/gemini-3.1-flash-image-preview
google/gemini-2.5-flash-image
google/gemini-3-pro-image-preview
gryphe/mythomax-l2-13b
ibm-granite/granite-4.0-h-micro
inception/mercury
inception/mercury-2
inception/mercury-coder
inflection/inflection-3-pi
inflection/inflection-3-productivity
kwaipilot/kat-coder-pro
kwaipilot/kat-coder-pro-v2
liquid/lfm-2-24b-a2b
liquid/lfm-2.2-6b
liquid/lfm-2.5-1.2b-instruct:free
liquid/lfm-2.5-1.2b-thinking:free
liquid/lfm2-8b-a1b
mancer/weaver
meituan/longcat-flash-chat
meta-llama/llama-guard-3-8b
meta-llama/llama-3.1-405b
meta-llama/llama-3.1-405b-instruct
meta-llama/llama-3.1-70b-instruct
meta-llama/llama-3.1-8b-instruct
meta-llama/llama-3.2-11b-vision-instruct
meta-llama/llama-3.2-1b-instruct
meta-llama/llama-3.2-3b-instruct
meta-llama/llama-3.2-3b-instruct:free
meta-llama/llama-3.3-70b-instruct
meta-llama/llama-3.3-70b-instruct:free
meta-llama/llama-3-70b-instruct
meta-llama/llama-3-8b-instruct
meta-llama/llama-4-maverick
meta-llama/llama-4-scout
meta-llama/llama-guard-2-8b
meta-llama/llama-guard-4-12b
microsoft/phi-4
microsoft/wizardlm-2-8x22b
minimax/minimax-01
minimax/minimax-m1
minimax/minimax-m2
minimax/minimax-m2.1
minimax/minimax-m2.5
minimax/minimax-m2.5:free
minimax/minimax-m2.7
minimax/minimax-m2-her
mistralai/codestral-2508
mistralai/devstral-2512
mistralai/devstral-medium
mistralai/devstral-small
mistralai/mistral-large
mistralai/mistral-large-2407
mistralai/mistral-large-2411
mistralai/ministral-14b-2512
mistralai/ministral-3b-2512
mistralai/ministral-8b-2512
mistralai/mistral-7b-instruct-v0.1
mistralai/mistral-large-2512
mistralai/mistral-medium-3
mistralai/mistral-medium-3.1
mistralai/mistral-nemo
mistralai/mistral-small-24b-instruct-2501
mistralai/mistral-small-3.1-24b-instruct
mistralai/mistral-small-3.1-24b-instruct:free
mistralai/mistral-small-3.2-24b-instruct
mistralai/mistral-small-2603
mistralai/mistral-small-creative
mistralai/mixtral-8x22b-instruct
mistralai/mixtral-8x7b-instruct
mistralai/pixtral-12b
mistralai/pixtral-large-2411
mistralai/mistral-saba
mistralai/voxtral-small-24b-2507
moonshotai/kimi-k2
moonshotai/kimi-k2-0905
moonshotai/kimi-k2-0905:exacto
moonshotai/kimi-k2.5
moonshotai/kimi-k2-thinking
morph/morph-v3-fast
morph/morph-v3-large
neversleep/llama-3.1-lumimaid-8b
neversleep/noromaid-20b
nex-agi/deepseek-v3.1-nex-n1
nousresearch/hermes-3-llama-3.1-405b
nousresearch/hermes-3-llama-3.1-405b:free
nousresearch/hermes-3-llama-3.1-70b
nousresearch/hermes-4-405b
nousresearch/hermes-4-70b
nousresearch/hermes-2-pro-llama-3-8b
nvidia/llama-3.1-nemotron-70b-instruct
nvidia/llama-3.1-nemotron-ultra-253b-v1
nvidia/llama-3.3-nemotron-super-49b-v1.5
nvidia/nemotron-3-nano-30b-a3b
nvidia/nemotron-3-nano-30b-a3b:free
nvidia/nemotron-3-super-120b-a12b
nvidia/nemotron-3-super-120b-a12b:free
nvidia/nemotron-nano-12b-v2-vl
nvidia/nemotron-nano-12b-v2-vl:free
nvidia/nemotron-nano-9b-v2
nvidia/nemotron-nano-9b-v2:free
openai/gpt-3.5-turbo
openai/gpt-3.5-turbo-16k
openai/gpt-3.5-turbo-instruct
openai/gpt-3.5-turbo-0613
openai/gpt-4
openai/gpt-4.1
openai/gpt-4.1-mini
openai/gpt-4.1-nano
openai/gpt-4o
openai/gpt-4o-2024-05-13
openai/gpt-4o-2024-08-06
openai/gpt-4o-2024-11-20
openai/gpt-4o-audio-preview
openai/gpt-4o:extended
openai/gpt-4-0314
openai/gpt-4o-mini
openai/gpt-4o-mini-2024-07-18
openai/gpt-4o-mini-search-preview
openai/gpt-4o-search-preview
openai/gpt-4-turbo
openai/gpt-4-1106-preview
openai/gpt-4-turbo-preview
openai/gpt-5
openai/gpt-5.1
openai/gpt-5.1-chat
openai/gpt-5.1-codex
openai/gpt-5.1-codex-max
openai/gpt-5.1-codex-mini
openai/gpt-5.2
openai/gpt-5.2-chat
openai/gpt-5.2-codex
openai/gpt-5.2-pro
openai/gpt-5.3-chat
openai/gpt-5.3-codex
openai/gpt-5.4
openai/gpt-5.4-mini
openai/gpt-5.4-nano
openai/gpt-5.4-pro
openai/gpt-5-chat
openai/gpt-5-codex
openai/gpt-5-image
openai/gpt-5-image-mini
openai/gpt-5-mini
openai/gpt-5-nano
openai/gpt-5-pro
openai/gpt-audio
openai/gpt-audio-mini
openai/gpt-oss-120b
openai/gpt-oss-120b:exacto
openai/gpt-oss-120b:free
openai/gpt-oss-20b
openai/gpt-oss-20b:free
openai/gpt-oss-safeguard-20b
openai/o1
openai/o1-pro
openai/o3
openai/o3-deep-research
openai/o3-mini
openai/o3-mini-high
openai/o3-pro
openai/o4-mini
openai/o4-mini-deep-research
openai/o4-mini-high
openrouter/free
openrouter/healer-alpha
openrouter/hunter-alpha
perplexity/sonar
perplexity/sonar-deep-research
perplexity/sonar-pro
perplexity/sonar-pro-search
perplexity/sonar-reasoning-pro
prime-intellect/intellect-3
qwen/qwen-2.5-72b-instruct
qwen/qwen-2.5-coder-32b-instruct
qwen/qwen-2.5-7b-instruct
qwen/qwen2.5-coder-7b-instruct
qwen/qwen2.5-vl-32b-instruct
qwen/qwen2.5-vl-72b-instruct
qwen/qwen-2.5-vl-7b-instruct
qwen/qwen3-14b
qwen/qwen3-235b-a22b
qwen/qwen3-235b-a22b-2507
qwen/qwen3-235b-a22b-thinking-2507
qwen/qwen3-30b-a3b
qwen/qwen3-30b-a3b-instruct-2507
qwen/qwen3-30b-a3b-thinking-2507
qwen/qwen3-32b
qwen/qwen3-4b:free
qwen/qwen3.5-122b-a10b
qwen/qwen3.5-27b
qwen/qwen3.5-35b-a3b
qwen/qwen3.5-397b-a17b
qwen/qwen3.5-9b
qwen/qwen3.5-flash-02-23
qwen/qwen3.5-plus-02-15
qwen/qwen3.6-plus
qwen/qwen3.6-plus:free
qwen/qwen3.6-plus-preview:free
qwen/qwen3-8b
qwen/qwen3-coder-30b-a3b-instruct
qwen/qwen3-coder
qwen/qwen3-coder:exacto
qwen/qwen3-coder:free
qwen/qwen3-coder-flash
qwen/qwen3-coder-next
qwen/qwen3-coder-plus
qwen/qwen3-max
qwen/qwen3-max-thinking
qwen/qwen3-next-80b-a3b-instruct
qwen/qwen3-next-80b-a3b-instruct:free
qwen/qwen3-next-80b-a3b-thinking
qwen/qwen3-vl-235b-a22b-instruct
qwen/qwen3-vl-235b-a22b-thinking
qwen/qwen3-vl-30b-a3b-instruct
qwen/qwen3-vl-30b-a3b-thinking
qwen/qwen3-vl-32b-instruct
qwen/qwen3-vl-8b-instruct
qwen/qwen3-vl-8b-thinking
qwen/qwen-max
qwen/qwen-plus
qwen/qwen-plus-2025-07-28
qwen/qwen-plus-2025-07-28:thinking
qwen/qwen-turbo
qwen/qwen-vl-max
qwen/qwen-vl-plus
qwen/qwq-32b
raifle/sorcererlm-8x22b
reka/reka-edge
rekaai/reka-edge
rekaai/reka-flash-3
relace/relace-apply-3
relace/relace-search
sao10k/l3.1-70b-hanami-x1
sao10k/l3.1-euryale-70b
sao10k/l3.3-euryale-70b
sao10k/l3-lunaris-8b
sao10k/l3-euryale-70b
stepfun/step-3.5-flash
stepfun/step-3.5-flash:free
switchpoint/router
tencent/hunyuan-a13b-instruct
thedrummer/cydonia-24b-v4.1
thedrummer/rocinante-12b
thedrummer/skyfall-36b-v2
thedrummer/unslopnemo-12b
tngtech/deepseek-r1t2-chimera
undi95/remm-slerp-l2-13b
upstage/solar-pro-3
writer/palmyra-x5
x-ai/grok-3
x-ai/grok-3-beta
x-ai/grok-3-mini
x-ai/grok-3-mini-beta
x-ai/grok-4
x-ai/grok-4.1-fast
x-ai/grok-4.20
x-ai/grok-4.20-beta
x-ai/grok-4.20-multi-agent
x-ai/grok-4.20-multi-agent-beta
x-ai/grok-4-fast
x-ai/grok-code-fast-1
xiaomi/mimo-v2-flash
xiaomi/mimo-v2-omni
xiaomi/mimo-v2-pro
z-ai/glm-4-32b
z-ai/glm-4.5
z-ai/glm-4.5-air
z-ai/glm-4.5-air:free
z-ai/glm-4.5v
z-ai/glm-4.6
z-ai/glm-4.6:exacto
z-ai/glm-4.6v
z-ai/glm-4.7
z-ai/glm-4.7-flash
z-ai/glm-5
z-ai/glm-5.1
z-ai/glm-5-turbo
z-ai/glm-5v-turbo
Use the REST API to send events from any language. The TypeScript and Python SDKs wrap this endpoint with automatic batching and retries — use the REST API directly for Go, Rust, Java, or any other language.
https://margindash.com/api/v1/events
Pass your API key as a Bearer token in the Authorization header. You can find your API key on the Settings page.
Send a single event with one vendor response:
curl -X POST https://margindash.com/api/v1/events \
-H "Authorization: Bearer YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"customer_id": "12345",
"event_type": "summarize",
"vendor_responses": [
{
"model": "openai/gpt-4o",
"input_tokens": 1200,
"output_tokens": 340
}
]
}
]
}'
{
"budget_state_version": 12,
"results": [
{
"id": 42,
"status": "created"
}
]
}
Used by SDK budget-guard flows. Poll this endpoint with since_version to avoid downloading unchanged state.
https://margindash.com/api/v1/budgets/blocklist?since_version=12
{
"version": 13,
"ttl_seconds": 30,
"changed": true,
"recompute_in_progress": false,
"blocked": {
"organization": false,
"event_types": ["summarize"],
"customer_ids": ["cust_123"]
}
}
{
"version": 13,
"ttl_seconds": 30,
"changed": false,
"recompute_in_progress": false
}
The request body is a JSON object with an events array. Each event accepts these fields:
| Field | Type | Required | Description |
|---|---|---|---|
| customer_id | string | yes | Your customer identifier. Auto-creates the customer if it doesn’t exist. |
| event_type | string | no | Category for this event, max 255 characters (default: ai_request) |
| vendor_responses | array | yes | Array of vendor response objects (see below). At least one required. |
| revenue_amount_in_cents | number | no | Revenue for this event in cents, 0–10,000,000, e.g. 1500 = $15.00 (default: 0) |
| occurred_at | string | no | ISO 8601 timestamp, e.g. 2025-06-15T14:30:00Z. Must be within the last 90 days and no more than 1 hour in the future. (default: current time) |
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | yes | AI model slug, e.g. openai/gpt-4o, anthropic/claude-opus-4 |
| input_tokens | number | yes | Input/prompt token count, 0–100,000,000. At least one of input_tokens or output_tokens must be > 0. |
| output_tokens | number | yes | Output/completion token count, 0–100,000,000 |
Click a vendor to see valid slugs for the model field. You can also fetch this list programmatically via GET /api/v1/models.
ai21/jamba-large-1.7
aion-labs/aion-1.0
aion-labs/aion-1.0-mini
aion-labs/aion-2.0
aion-labs/aion-rp-llama-3.1-8b
alfredpros/codellama-7b-instruct-solidity
alibaba/tongyi-deepresearch-30b-a3b
allenai/molmo-2-8b
allenai/olmo-2-0325-32b-instruct
allenai/olmo-3.1-32b-instruct
allenai/olmo-3.1-32b-think
allenai/olmo-3-32b-think
allenai/olmo-3-7b-instruct
allenai/olmo-3-7b-think
alpindale/goliath-120b
amazon/nova-2-lite-v1
amazon/nova-lite-v1
amazon/nova-micro-v1
amazon/nova-premier-v1
amazon/nova-pro-v1
anthracite-org/magnum-v4-72b
anthropic/claude-3.5-haiku
anthropic/claude-3.5-sonnet
anthropic/claude-3.7-sonnet
anthropic/claude-3.7-sonnet:thinking
anthropic/claude-3-haiku
anthropic/claude-haiku-4.5
anthropic/claude-opus-4
anthropic/claude-opus-4.1
anthropic/claude-opus-4.5
anthropic/claude-opus-4.6
anthropic/claude-opus-4.6-fast
anthropic/claude-sonnet-4
anthropic/claude-sonnet-4.5
anthropic/claude-sonnet-4.6
arcee-ai/coder-large
arcee-ai/maestro-reasoning
arcee-ai/spotlight
arcee-ai/trinity-large-preview:free
arcee-ai/trinity-large-thinking
arcee-ai/trinity-mini
arcee-ai/trinity-mini:free
arcee-ai/virtuoso-large
baidu/ernie-4.5-21b-a3b
baidu/ernie-4.5-21b-a3b-thinking
baidu/ernie-4.5-300b-a47b
baidu/ernie-4.5-vl-28b-a3b
baidu/ernie-4.5-vl-424b-a47b
bytedance/ui-tars-1.5-7b
bytedance-seed/seed-1.6
bytedance-seed/seed-1.6-flash
bytedance-seed/seed-2.0-lite
bytedance-seed/seed-2.0-mini
cognitivecomputations/dolphin-mistral-24b-venice-edition:free
cohere/command-a
cohere/command-r-08-2024
cohere/command-r-plus-08-2024
cohere/command-r7b-12-2024
deepcogito/cogito-v2.1-671b
deepseek/deepseek-chat
deepseek/deepseek-chat-v3-0324
deepseek/deepseek-chat-v3.1
deepseek/deepseek-v3.1-terminus
deepseek/deepseek-v3.1-terminus:exacto
deepseek/deepseek-v3.2
deepseek/deepseek-v3.2-exp
deepseek/deepseek-v3.2-speciale
deepseek/deepseek-r1
deepseek/deepseek-r1-0528
deepseek/deepseek-r1-distill-llama-70b
deepseek/deepseek-r1-distill-qwen-32b
eleutherai/llemma_7b
essentialai/rnj-1-instruct
google/gemini-2.0-flash-001
google/gemini-2.0-flash-lite-001
google/gemini-2.5-flash
google/gemini-2.5-flash-lite
google/gemini-2.5-flash-lite-preview-09-2025
google/gemini-2.5-pro
google/gemini-2.5-pro-preview-05-06
google/gemini-2.5-pro-preview
google/gemini-3.1-flash-lite-preview
google/gemini-3.1-pro-preview
google/gemini-3.1-pro-preview-customtools
google/gemini-3-flash-preview
google/gemini-3-pro-preview
google/gemma-2-27b-it
google/gemma-2-9b-it
google/gemma-3-12b-it
google/gemma-3-12b-it:free
google/gemma-3-27b-it
google/gemma-3-27b-it:free
google/gemma-3-4b-it
google/gemma-3-4b-it:free
google/gemma-3n-e2b-it:free
google/gemma-3n-e4b-it
google/gemma-3n-e4b-it:free
google/gemma-4-26b-a4b-it
google/gemma-4-26b-a4b-it:free
google/gemma-4-31b-it
google/gemma-4-31b-it:free
google/lyria-3-clip-preview
google/lyria-3-pro-preview
google/gemini-3.1-flash-image-preview
google/gemini-2.5-flash-image
google/gemini-3-pro-image-preview
gryphe/mythomax-l2-13b
ibm-granite/granite-4.0-h-micro
inception/mercury
inception/mercury-2
inception/mercury-coder
inflection/inflection-3-pi
inflection/inflection-3-productivity
kwaipilot/kat-coder-pro
kwaipilot/kat-coder-pro-v2
liquid/lfm-2-24b-a2b
liquid/lfm-2.2-6b
liquid/lfm-2.5-1.2b-instruct:free
liquid/lfm-2.5-1.2b-thinking:free
liquid/lfm2-8b-a1b
mancer/weaver
meituan/longcat-flash-chat
meta-llama/llama-guard-3-8b
meta-llama/llama-3.1-405b
meta-llama/llama-3.1-405b-instruct
meta-llama/llama-3.1-70b-instruct
meta-llama/llama-3.1-8b-instruct
meta-llama/llama-3.2-11b-vision-instruct
meta-llama/llama-3.2-1b-instruct
meta-llama/llama-3.2-3b-instruct
meta-llama/llama-3.2-3b-instruct:free
meta-llama/llama-3.3-70b-instruct
meta-llama/llama-3.3-70b-instruct:free
meta-llama/llama-3-70b-instruct
meta-llama/llama-3-8b-instruct
meta-llama/llama-4-maverick
meta-llama/llama-4-scout
meta-llama/llama-guard-2-8b
meta-llama/llama-guard-4-12b
microsoft/phi-4
microsoft/wizardlm-2-8x22b
minimax/minimax-01
minimax/minimax-m1
minimax/minimax-m2
minimax/minimax-m2.1
minimax/minimax-m2.5
minimax/minimax-m2.5:free
minimax/minimax-m2.7
minimax/minimax-m2-her
mistralai/codestral-2508
mistralai/devstral-2512
mistralai/devstral-medium
mistralai/devstral-small
mistralai/mistral-large
mistralai/mistral-large-2407
mistralai/mistral-large-2411
mistralai/ministral-14b-2512
mistralai/ministral-3b-2512
mistralai/ministral-8b-2512
mistralai/mistral-7b-instruct-v0.1
mistralai/mistral-large-2512
mistralai/mistral-medium-3
mistralai/mistral-medium-3.1
mistralai/mistral-nemo
mistralai/mistral-small-24b-instruct-2501
mistralai/mistral-small-3.1-24b-instruct
mistralai/mistral-small-3.1-24b-instruct:free
mistralai/mistral-small-3.2-24b-instruct
mistralai/mistral-small-2603
mistralai/mistral-small-creative
mistralai/mixtral-8x22b-instruct
mistralai/mixtral-8x7b-instruct
mistralai/pixtral-12b
mistralai/pixtral-large-2411
mistralai/mistral-saba
mistralai/voxtral-small-24b-2507
moonshotai/kimi-k2
moonshotai/kimi-k2-0905
moonshotai/kimi-k2-0905:exacto
moonshotai/kimi-k2.5
moonshotai/kimi-k2-thinking
morph/morph-v3-fast
morph/morph-v3-large
neversleep/llama-3.1-lumimaid-8b
neversleep/noromaid-20b
nex-agi/deepseek-v3.1-nex-n1
nousresearch/hermes-3-llama-3.1-405b
nousresearch/hermes-3-llama-3.1-405b:free
nousresearch/hermes-3-llama-3.1-70b
nousresearch/hermes-4-405b
nousresearch/hermes-4-70b
nousresearch/hermes-2-pro-llama-3-8b
nvidia/llama-3.1-nemotron-70b-instruct
nvidia/llama-3.1-nemotron-ultra-253b-v1
nvidia/llama-3.3-nemotron-super-49b-v1.5
nvidia/nemotron-3-nano-30b-a3b
nvidia/nemotron-3-nano-30b-a3b:free
nvidia/nemotron-3-super-120b-a12b
nvidia/nemotron-3-super-120b-a12b:free
nvidia/nemotron-nano-12b-v2-vl
nvidia/nemotron-nano-12b-v2-vl:free
nvidia/nemotron-nano-9b-v2
nvidia/nemotron-nano-9b-v2:free
openai/gpt-3.5-turbo
openai/gpt-3.5-turbo-16k
openai/gpt-3.5-turbo-instruct
openai/gpt-3.5-turbo-0613
openai/gpt-4
openai/gpt-4.1
openai/gpt-4.1-mini
openai/gpt-4.1-nano
openai/gpt-4o
openai/gpt-4o-2024-05-13
openai/gpt-4o-2024-08-06
openai/gpt-4o-2024-11-20
openai/gpt-4o-audio-preview
openai/gpt-4o:extended
openai/gpt-4-0314
openai/gpt-4o-mini
openai/gpt-4o-mini-2024-07-18
openai/gpt-4o-mini-search-preview
openai/gpt-4o-search-preview
openai/gpt-4-turbo
openai/gpt-4-1106-preview
openai/gpt-4-turbo-preview
openai/gpt-5
openai/gpt-5.1
openai/gpt-5.1-chat
openai/gpt-5.1-codex
openai/gpt-5.1-codex-max
openai/gpt-5.1-codex-mini
openai/gpt-5.2
openai/gpt-5.2-chat
openai/gpt-5.2-codex
openai/gpt-5.2-pro
openai/gpt-5.3-chat
openai/gpt-5.3-codex
openai/gpt-5.4
openai/gpt-5.4-mini
openai/gpt-5.4-nano
openai/gpt-5.4-pro
openai/gpt-5-chat
openai/gpt-5-codex
openai/gpt-5-image
openai/gpt-5-image-mini
openai/gpt-5-mini
openai/gpt-5-nano
openai/gpt-5-pro
openai/gpt-audio
openai/gpt-audio-mini
openai/gpt-oss-120b
openai/gpt-oss-120b:exacto
openai/gpt-oss-120b:free
openai/gpt-oss-20b
openai/gpt-oss-20b:free
openai/gpt-oss-safeguard-20b
openai/o1
openai/o1-pro
openai/o3
openai/o3-deep-research
openai/o3-mini
openai/o3-mini-high
openai/o3-pro
openai/o4-mini
openai/o4-mini-deep-research
openai/o4-mini-high
openrouter/free
openrouter/healer-alpha
openrouter/hunter-alpha
perplexity/sonar
perplexity/sonar-deep-research
perplexity/sonar-pro
perplexity/sonar-pro-search
perplexity/sonar-reasoning-pro
prime-intellect/intellect-3
qwen/qwen-2.5-72b-instruct
qwen/qwen-2.5-coder-32b-instruct
qwen/qwen-2.5-7b-instruct
qwen/qwen2.5-coder-7b-instruct
qwen/qwen2.5-vl-32b-instruct
qwen/qwen2.5-vl-72b-instruct
qwen/qwen-2.5-vl-7b-instruct
qwen/qwen3-14b
qwen/qwen3-235b-a22b
qwen/qwen3-235b-a22b-2507
qwen/qwen3-235b-a22b-thinking-2507
qwen/qwen3-30b-a3b
qwen/qwen3-30b-a3b-instruct-2507
qwen/qwen3-30b-a3b-thinking-2507
qwen/qwen3-32b
qwen/qwen3-4b:free
qwen/qwen3.5-122b-a10b
qwen/qwen3.5-27b
qwen/qwen3.5-35b-a3b
qwen/qwen3.5-397b-a17b
qwen/qwen3.5-9b
qwen/qwen3.5-flash-02-23
qwen/qwen3.5-plus-02-15
qwen/qwen3.6-plus
qwen/qwen3.6-plus:free
qwen/qwen3.6-plus-preview:free
qwen/qwen3-8b
qwen/qwen3-coder-30b-a3b-instruct
qwen/qwen3-coder
qwen/qwen3-coder:exacto
qwen/qwen3-coder:free
qwen/qwen3-coder-flash
qwen/qwen3-coder-next
qwen/qwen3-coder-plus
qwen/qwen3-max
qwen/qwen3-max-thinking
qwen/qwen3-next-80b-a3b-instruct
qwen/qwen3-next-80b-a3b-instruct:free
qwen/qwen3-next-80b-a3b-thinking
qwen/qwen3-vl-235b-a22b-instruct
qwen/qwen3-vl-235b-a22b-thinking
qwen/qwen3-vl-30b-a3b-instruct
qwen/qwen3-vl-30b-a3b-thinking
qwen/qwen3-vl-32b-instruct
qwen/qwen3-vl-8b-instruct
qwen/qwen3-vl-8b-thinking
qwen/qwen-max
qwen/qwen-plus
qwen/qwen-plus-2025-07-28
qwen/qwen-plus-2025-07-28:thinking
qwen/qwen-turbo
qwen/qwen-vl-max
qwen/qwen-vl-plus
qwen/qwq-32b
raifle/sorcererlm-8x22b
reka/reka-edge
rekaai/reka-edge
rekaai/reka-flash-3
relace/relace-apply-3
relace/relace-search
sao10k/l3.1-70b-hanami-x1
sao10k/l3.1-euryale-70b
sao10k/l3.3-euryale-70b
sao10k/l3-lunaris-8b
sao10k/l3-euryale-70b
stepfun/step-3.5-flash
stepfun/step-3.5-flash:free
switchpoint/router
tencent/hunyuan-a13b-instruct
thedrummer/cydonia-24b-v4.1
thedrummer/rocinante-12b
thedrummer/skyfall-36b-v2
thedrummer/unslopnemo-12b
tngtech/deepseek-r1t2-chimera
undi95/remm-slerp-l2-13b
upstage/solar-pro-3
writer/palmyra-x5
x-ai/grok-3
x-ai/grok-3-beta
x-ai/grok-3-mini
x-ai/grok-3-mini-beta
x-ai/grok-4
x-ai/grok-4.1-fast
x-ai/grok-4.20
x-ai/grok-4.20-beta
x-ai/grok-4.20-multi-agent
x-ai/grok-4.20-multi-agent-beta
x-ai/grok-4-fast
x-ai/grok-code-fast-1
xiaomi/mimo-v2-flash
xiaomi/mimo-v2-omni
xiaomi/mimo-v2-pro
z-ai/glm-4-32b
z-ai/glm-4.5
z-ai/glm-4.5-air
z-ai/glm-4.5-air:free
z-ai/glm-4.5v
z-ai/glm-4.6
z-ai/glm-4.6:exacto
z-ai/glm-4.6v
z-ai/glm-4.7
z-ai/glm-4.7-flash
z-ai/glm-5
z-ai/glm-5.1
z-ai/glm-5-turbo
z-ai/glm-5v-turbo
Store your customer_id in the Stripe customer's
metadata, and our invoice sync will automatically
match Stripe payments to the correct customer in your dashboard. This ensures that invoice revenue
is attributed to the same customer as your events, enabling accurate margin calculations.
Store your customer ID in the Stripe customer's metadata:
curl https://api.stripe.com/v1/customers \
-u "sk_live_YOUR_KEY:" \
-d "name=Acme Corp" \
-d "email=billing@acme.com" \
-d "metadata[customer_id]=12345"
Developer Note
The ID you pass to Stripe (12345) must exactly match the
customer_id you send in your events.
If these values don't match, MarginDash cannot link subscription revenue to usage costs, and margin calculations will be inaccurate.
If you already have Stripe customers, you can backfill the metadata[customer_id]
with a one-time script. Loop through your customers and update each one with your internal ID.
Existing invoices are automatically re-linked when you update the metadata — no manual re-sync needed.
import Stripe from "stripe";
const stripe = new Stripe("sk_live_YOUR_KEY");
// Your mapping of Stripe customer IDs to internal IDs
const customerMap: Record<string, string> = {
"cus_ABC123": "12345",
"cus_DEF456": "67890",
};
for (const [stripeId, internalId] of Object.entries(customerMap)) {
await stripe.customers.update(stripeId, {
metadata: { customer_id: internalId },
});
}
import stripe
stripe.api_key = "sk_live_YOUR_KEY"
# Your mapping of Stripe customer IDs to internal IDs
customer_map = {
"cus_ABC123": "12345",
"cus_DEF456": "67890",
}
for stripe_id, internal_id in customer_map.items():
stripe.Customer.modify(
stripe_id,
metadata={"customer_id": internal_id},
)