How to pass your API key to the SDK and override the base URL.
The Spine API uses API keys sent as the X-API-KEY request header. The
SDK adds the header for you on every request — you just need to give it
a key.
Passing the key
// Shell:// export SPINE_API_KEY=sk_spine_...import { Spine } from 'spine-sdk';const client = new Spine({ apiKey: process.env.SPINE_API_KEY! });
import { Spine } from 'spine-sdk';const client = new Spine({ apiKey: 'sk_spine_...' });
Never commit keys to source control. Use your deployment platform’s
secret manager (AWS Secrets Manager, 1Password, Doppler, etc.) and
inject them at runtime. Never ship keys to the browser — proxy requests
through your own backend instead.
If apiKey is falsy, the Spine constructor throws immediately — before
any network call.
Key rotation
Keys revoked in the dashboard stop working on the next request; you’ll
see SpineAuthError thrown from the SDK. Roll new keys through your
secret store before revoking the old one so running processes don’t
break mid-run. The server caches keys for up to 5 minutes, so leave that
grace window.
Overriding the base URL
Point the SDK at a staging or enterprise deployment via baseURL:
const client = new Spine({ apiKey: process.env.SPINE_API_KEY!, baseURL: 'https://staging.getspine.ai',});
The SDK appends /v1 paths automatically, so pass the host without the
API prefix.
For advanced cases (custom proxies, test doubles, alternative runtimes),
pass a pre-configured fetch implementation. The SDK still applies
X-API-KEY and User-Agent headers — your implementation does not need
to set them.
import undici from 'undici';const client = new Spine({ apiKey: process.env.SPINE_API_KEY!, fetch: undici.fetch as typeof fetch,});
Observing requests
Use onRequest and onResponse for tracing every call:
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Spine Documentation","description":"The highest-quality research API. #1 on GAIA Level 3 — verified, auditable multi-agent research delivered as polished artifacts via a single API call. Plus Spine Canvas, a visual multi-agent workspace.","colors":{"primary":"#6e56cf","light":"#9d86ff","dark":"#6e56cf"},"logo":{"light":"https://mintcdn.com/spineai/t8hvI4O_HYGJeQrn/logo/spine-logos/logo-black-full.svg?fit=max\u0026auto=format\u0026n=t8hvI4O_HYGJeQrn\u0026q=85\u0026s=0158b96e864b6d8ee6826a0d8bebfe39","dark":"https://mintcdn.com/spineai/t8hvI4O_HYGJeQrn/logo/spine-logos/logo-white-full.svg?fit=max\u0026auto=format\u0026n=t8hvI4O_HYGJeQrn\u0026q=85\u0026s=98cc979fb7cfb7997d201420a9780857"},"favicon":"https://mintcdn.com/spineai/t8hvI4O_HYGJeQrn/logo/spine-logos/favicon.svg?fit=max\u0026auto=format\u0026n=t8hvI4O_HYGJeQrn\u0026q=85\u0026s=4c6841d66822c1a199bc29a79f8bc551","api":{"playground":{"display":"none"}},"appearance":{"default":"dark"},"background":{"decoration":"gradient","color":{"light":"#FAFAF9","dark":"#0B0B0C"}},"navbar":{"links":[{"href":"mailto:support@getspine.ai","label":"Support"}],"primary":{"type":"button","label":"Developer Portal","href":"https://platform.getspine.ai"}},"footer":{"socials":{"x":"https://x.com/Spine_AI","linkedin":"https://www.linkedin.com/company/spine-ai"}},"fonts":{"heading":{"family":"Inter","weight":600},"body":{"family":"Inter","weight":400}},"styling":{"eyebrows":"breadcrumbs","codeblocks":{"theme":{"light":"github-light","dark":"tokyo-night"}},"latex":true},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"spineai","hasAudioNarration":false,"actualSubdomain":"spineai","customDomains":["docs.getspine.ai"],"gitSource":{"type":"github","owner":"spine-ai","repo":"documentation","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae91ea1ab2971a8eb0c525d:success","clientVersion":"0.0.4342","searchFilterCounts":[{"language":"default","tag":"Spine API","count":44},{"language":"default","tag":"Spine App","count":40},{"language":"default","tag":"Blocks","count":21},{"language":"default","tag":"Advanced Features","count":8},{"language":"default","tag":"Python SDK","count":8},{"language":"default","tag":"TypeScript SDK","count":8},{"language":"default","tag":"Concepts","count":7},{"language":"default","tag":"The Canvas","count":7},{"language":"default","tag":"Endpoints","count":5},{"language":"default","tag":"Use with agents","count":5}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[{"filePath":"custom.css","content":"nav[data-sidebar] a,aside a{padding-top:0.35rem;padding-bottom:0.35rem;font-size:0.875rem;letter-spacing:0.005em}header a[role=\"button\"],header a.primary-cta,a[data-primary=\"true\"]{border-radius:9999px!important;padding:0.5rem 1.1rem;font-weight:500}pre,pre code,.code-block,[class*=\"code-block\"]{border-radius:6px;font-family:\"JetBrains Mono\", ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.85rem;line-height:1.55}main article,main [class*=\"prose\"]{max-width:72ch}main a{text-underline-offset:3px;text-decoration-thickness:1px}[class*=\"card\"]:hover{transform:translateY(-1px);transition:transform 120ms ease}"}]}
{"page":{"pagePath":"sdks/typescript/authentication","slug":"/sdks/typescript/authentication","pageMetadata":{"title":"Authentication","description":"How to pass your API key to the SDK and override the base URL.","href":"/sdks/typescript/authentication"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"How to pass your API key to the SDK and override the base URL.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`The Spine API uses API keys sent as the `,_jsx(_components.code,{children:`X-API-KEY`}),` request header. The\nSDK adds the header for you on every request — you just need to give it\na key.`]}),`\n`,_jsx(Heading,{level:`2`,id:`passing-the-key`,children:`Passing the key`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Environment variable (preferred)`,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light tokyo-night`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#1a1b26`,color:`#24292e`,\"--shiki-dark\":`#a9b1d6`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#51597D`,\"--shiki-dark-font-style\":`italic`},children:`// Shell:`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#51597D`,\"--shiki-dark-font-style\":`italic`},children:`// export SPINE_API_KEY=sk_spine_...`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#7DCFFF`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` { `}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#0DB9D7`},children:`Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` }`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#7DCFFF`},children:` from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:` '`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`spine-sdk`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#9D7CD8`,\"--shiki-dark-font-style\":`italic`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#BB9AF7`},children:` client`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`({`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` process`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:`env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#FF9E64`},children:`SPINE_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#BB9AF7`},children:`!`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` })`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Explicit argument`,numberOfLines:`3`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light tokyo-night`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#1a1b26`,color:`#24292e`,\"--shiki-dark\":`#a9b1d6`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#7DCFFF`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` { `}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#0DB9D7`},children:`Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` }`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#7DCFFF`},children:` from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:` '`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`spine-sdk`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#9D7CD8`,\"--shiki-dark-font-style\":`italic`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#BB9AF7`},children:` client`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`({`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:` '`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`sk_spine_...`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` })`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`]})})})]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Never commit keys to source control. Use your deployment platform’s\nsecret manager (AWS Secrets Manager, 1Password, Doppler, etc.) and\ninject them at runtime. Never ship keys to the browser — proxy requests\nthrough your own backend instead.`})}),`\n`,_jsxs(_components.p,{children:[`If `,_jsx(_components.code,{children:`apiKey`}),` is falsy, the `,_jsx(_components.code,{children:`Spine`}),` constructor throws immediately — before\nany network call.`]}),`\n`,_jsx(Heading,{level:`2`,id:`key-rotation`,children:`Key rotation`}),`\n`,_jsxs(_components.p,{children:[`Keys revoked in the dashboard stop working on the next request; you’ll\nsee `,_jsx(_components.code,{children:`SpineAuthError`}),` thrown from the SDK. Roll new keys through your\nsecret store before revoking the old one so running processes don’t\nbreak mid-run. The server caches keys for up to 5 minutes, so leave that\ngrace window.`]}),`\n`,_jsx(Heading,{level:`2`,id:`overriding-the-base-url`,children:`Overriding the base URL`}),`\n`,_jsxs(_components.p,{children:[`Point the SDK at a staging or enterprise deployment via `,_jsx(_components.code,{children:`baseURL`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light tokyo-night`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#1a1b26`,color:`#24292e`,\"--shiki-dark\":`#a9b1d6`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#9D7CD8`,\"--shiki-dark-font-style\":`italic`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#BB9AF7`},children:` client`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` process`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:`env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#FF9E64`},children:`SPINE_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#BB9AF7`},children:`!`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` baseURL`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:` '`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`https://staging.getspine.ai`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`})`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The SDK appends `,_jsx(_components.code,{children:`/v1`}),` paths automatically, so pass the host without the\nAPI prefix.`]}),`\n`,_jsx(Heading,{level:`2`,id:`tuning-timeouts-and-retries`,children:`Tuning timeouts and retries`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light tokyo-night`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#1a1b26`,color:`#24292e`,\"--shiki-dark\":`#a9b1d6`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#9D7CD8`,\"--shiki-dark-font-style\":`italic`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#BB9AF7`},children:` client`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` process`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:`env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#FF9E64`},children:`SPINE_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#BB9AF7`},children:`!`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` timeoutMs`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#FF9E64`},children:` 60_000`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#51597D`,\"--shiki-dark-font-style\":`italic`},children:` // per-request timeout (default: 60_000)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` maxRetries`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#FF9E64`},children:` 2`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#6A737D`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#51597D`,\"--shiki-dark-font-style\":`italic`},children:` // transient 5xx / network retries (default: 2)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`})`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/sdks/typescript/errors`,children:`Errors and retries`}),` for the retry policy.`]}),`\n`,_jsx(Heading,{level:`2`,id:`injecting-your-own-fetch`,children:`Injecting your own fetch`}),`\n`,_jsxs(_components.p,{children:[`For advanced cases (custom proxies, test doubles, alternative runtimes),\npass a pre-configured `,_jsx(_components.code,{children:`fetch`}),` implementation. The SDK still applies\n`,_jsx(_components.code,{children:`X-API-KEY`}),` and `,_jsx(_components.code,{children:`User-Agent`}),` headers — your implementation does not need\nto set them.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light tokyo-night`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#1a1b26`,color:`#24292e`,\"--shiki-dark\":`#a9b1d6`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#7DCFFF`},children:`import`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#0DB9D7`},children:` undici`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#7DCFFF`},children:` from`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:` '`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`undici`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#9D7CD8`,\"--shiki-dark-font-style\":`italic`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#BB9AF7`},children:` client`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` process`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:`env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#FF9E64`},children:`SPINE_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#BB9AF7`},children:`!`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` undici`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#7DCFFF`},children:`fetch`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` as`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` typeof`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` fetch`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`})`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`observing-requests`,children:`Observing requests`}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`onRequest`}),` and `,_jsx(_components.code,{children:`onResponse`}),` for tracing every call:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light tokyo-night`,style:{backgroundColor:`#fff`,\"--shiki-dark-bg\":`#1a1b26`,color:`#24292e`,\"--shiki-dark\":`#a9b1d6`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-light-font-style\":`inherit`,\"--shiki-dark\":`#9D7CD8`,\"--shiki-dark-font-style\":`italic`},children:`const`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#BB9AF7`},children:` client`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` =`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#89DDFF`},children:` new`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` Spine`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#73DACA`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` process`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:`env`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#005CC5`,\"--shiki-dark\":`#FF9E64`},children:`SPINE_API_KEY`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#BB9AF7`},children:`!`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` onRequest`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` (`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`{`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#E0AF68`},children:` method`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#E0AF68`},children:` url`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:` }`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`)`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#BB9AF7`},children:` =>`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` console`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:`debug`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`(`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`[spine]`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` method`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` url`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`)`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:` onResponse`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`:`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:` (`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`{`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#E0AF68`},children:` status`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#E36209`,\"--shiki-dark\":`#E0AF68`},children:` durationMs`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:` }`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`)`}),_jsx(_components.span,{style:{color:`#D73A49`,\"--shiki-dark\":`#BB9AF7`},children:` =>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` console`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`.`}),_jsx(_components.span,{style:{color:`#6F42C1`,\"--shiki-dark\":`#7AA2F7`},children:`debug`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`(`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`[spine]`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:`'`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:` status`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:\" `\"}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#7DCFFF`},children:\"${\"}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#C0CAF5`},children:`durationMs`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#7DCFFF`},children:`}`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#9ECE6A`},children:`ms`}),_jsx(_components.span,{style:{color:`#032F62`,\"--shiki-dark\":`#89DDFF`},children:\"`\"}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`)`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#9ABDF5`},children:`})`}),_jsx(_components.span,{style:{color:`#24292E`,\"--shiki-dark\":`#89DDFF`},children:`;`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"github-light","dark":"tokyo-night"}},"config":{},"pageMetadata":{"title":"Authentication","description":"How to pass your API key to the SDK and override the base URL.","href":"/sdks/typescript/authentication"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Passing the key","slug":"passing-the-key","depth":2,"children":[]},{"title":"Key rotation","slug":"key-rotation","depth":2,"children":[]},{"title":"Overriding the base URL","slug":"overriding-the-base-url","depth":2,"children":[]},{"title":"Tuning timeouts and retries","slug":"tuning-timeouts-and-retries","depth":2,"children":[]},{"title":"Injecting your own fetch","slug":"injecting-your-own-fetch","depth":2,"children":[]},{"title":"Observing requests","slug":"observing-requests","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/spineai/4315a4734dcfd3ba/scripts/per-tab-cta.js"],"subdomain":"spineai","siteName":"Spine Documentation","title":"Authentication - Spine Documentation","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-04-17T05:06:21.655Z","originalFileLocation":"sdks/typescript/authentication.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"How to pass your API key to the SDK and override the base URL.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Spine Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Authentication - Spine Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"How to pass your API key to the SDK and override the base URL.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Spine Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.getspine.ai/sdks/typescript/authentication\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://spineai.mintlify.site/_mintlify/api/og/v2?division=TypeScript+SDK\u0026amp;title=Authentication\u0026amp;description=How+to+pass+your+API+key+to+the+SDK+and+override+the+base+URL.\u0026amp;theme=7c94212fecbb318c6aea9fa1\u0026amp;signature=921ae2e2f6804a1b218fc79f9878157a55b319309923ecddf0183fd7b35c7989\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Authentication - Spine Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How to pass your API key to the SDK and override the base URL.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://spineai.mintlify.site/_mintlify/api/og/v2?division=TypeScript+SDK\u0026amp;title=Authentication\u0026amp;description=How+to+pass+your+API+key+to+the+SDK+and+override+the+base+URL.\u0026amp;theme=7c94212fecbb318c6aea9fa1\u0026amp;signature=921ae2e2f6804a1b218fc79f9878157a55b319309923ecddf0183fd7b35c7989\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/spineai/sFPsSa1SIGxYmv5T/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Spine Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#6e56cf\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.getspine.ai/sdks/typescript/authentication\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/sdks/typescript/authentication.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.getspine.ai/#organization\",\"name\":\"Spine Documentation\",\"url\":\"https://docs.getspine.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/spineai/t8hvI4O_HYGJeQrn/logo/spine-logos/logo-black-full.svg?fit=max\u0026auto=format\u0026n=t8hvI4O_HYGJeQrn\u0026q=85\u0026s=0158b96e864b6d8ee6826a0d8bebfe39\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.getspine.ai#website\",\"name\":\"Spine Documentation\",\"url\":\"https://docs.getspine.ai\",\"publisher\":{\"@id\":\"https://docs.getspine.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.getspine.ai/sdks/typescript/authentication#webpage\",\"url\":\"https://docs.getspine.ai/sdks/typescript/authentication\",\"name\":\"Authentication\",\"description\":\"How to pass your API key to the SDK and override the base URL.\",\"dateModified\":\"2026-04-17T05:06:21.655Z\",\"isPartOf\":{\"@id\":\"https://docs.getspine.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.getspine.ai/sdks/typescript/authentication#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.getspine.ai/sdks/typescript/authentication#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"TypeScript SDK\",\"item\":\"https://docs.getspine.ai/sdks/typescript/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Authentication\",\"item\":\"https://docs.getspine.ai/sdks/typescript/authentication\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.getspine.ai/sdks/typescript/authentication#article\",\"headline\":\"Authentication\",\"name\":\"Authentication\",\"description\":\"How to pass your API key to the SDK and override the base URL.\",\"url\":\"https://docs.getspine.ai/sdks/typescript/authentication\",\"mainEntityOfPage\":{\"@id\":\"https://docs.getspine.ai/sdks/typescript/authentication#webpage\"},\"dateModified\":\"2026-04-17T05:06:21.655Z\",\"publisher\":{\"@id\":\"https://docs.getspine.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.getspine.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Spine Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Spine Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/sdks/typescript/authentication.md","siteName":"Spine Documentation","nav":{"global":null,"tabs":[{"tab":"Spine API","groups":[{"group":"Get Started","pages":[{"title":"Spine API","sidebarTitle":"Overview","href":"/api-reference/overview"},{"title":"Quickstart","href":"/api-reference/quickstart"},{"title":"Authentication","href":"/api-reference/authentication"}]},{"group":"Concepts","pages":[{"title":"Canvases and runs","href":"/api-reference/concepts/canvases-and-runs"},{"title":"Templates","href":"/api-reference/concepts/templates"},{"title":"Block types","href":"/api-reference/concepts/block-types"},{"title":"Agent instructions","href":"/api-reference/concepts/agent-instructions"},{"title":"File uploads","href":"/api-reference/concepts/file-uploads"},{"title":"Webhooks","href":"/api-reference/concepts/webhooks"},{"title":"Polling and status","sidebarTitle":"Polling and status (alternative)","href":"/api-reference/concepts/polling-and-status"}]},{"group":"Use with agents","pages":[{"title":"Claude Code","href":"/api-reference/integrations/claude-code"},{"title":"OpenClaw","href":"/api-reference/integrations/openclaw"},{"title":"Codex CLI","href":"/api-reference/integrations/codex-cli"},{"title":"Cursor","href":"/api-reference/integrations/cursor"},{"title":"Bolt, Replit, Lovable","href":"/api-reference/integrations/web-builders"}]},{"group":"Endpoints","pages":[{"title":"Create a run","openapi":"POST /v1/run","href":"/api-reference/endpoints/create-run"},{"title":"Get a run","openapi":"GET /v1/run/{run_id}","href":"/api-reference/endpoints/get-run"},{"title":"Get canvas DAG","openapi":"GET /v1/canvas/{canvas_id}/dag","href":"/api-reference/endpoints/get-canvas-dag"},{"title":"Get task tree","openapi":"GET /v1/canvas/{canvas_id}/tasks","href":"/api-reference/endpoints/get-canvas-tasks"},{"title":"Get a single task","openapi":"GET /v1/canvas/{canvas_id}/tasks/{task_id}","href":"/api-reference/endpoints/get-task"}]},{"group":"Resources","pages":[{"title":"Errors","href":"/api-reference/errors"},{"title":"For agents","href":"/api-reference/for-agents"},{"title":"SDKs","href":"/api-reference/sdks"}]},{"group":"Python SDK","pages":[{"title":"Python SDK","href":"/sdks/python/overview"},{"title":"Quickstart","href":"/sdks/python/quickstart"},{"title":"Authentication","href":"/sdks/python/authentication"},{"title":"Runs and polling","href":"/sdks/python/runs"},{"title":"Canvas introspection","href":"/sdks/python/canvas"},{"title":"Webhooks","href":"/sdks/python/webhooks"},{"title":"Errors and retries","href":"/sdks/python/errors"},{"title":"API reference","href":"/sdks/python/reference"}]},{"group":"TypeScript SDK","pages":[{"title":"TypeScript SDK","href":"/sdks/typescript/overview"},{"title":"Quickstart","description":"Install the SDK and run your first end-to-end request.","href":"/sdks/typescript/quickstart"},{"title":"Authentication","href":"/sdks/typescript/authentication"},{"title":"Runs and polling","description":"Create runs, wait for them, and poll progress with the TypeScript SDK.","href":"/sdks/typescript/runs"},{"title":"Canvas introspection","href":"/sdks/typescript/canvas"},{"title":"Webhooks","href":"/sdks/typescript/webhooks"},{"title":"Errors and retries","href":"/sdks/typescript/errors"},{"title":"API reference","href":"/sdks/typescript/reference"}]},{"group":"Runs","pages":[{"title":"Create a canvas run","deprecated":null,"version":null,"openapi":"/openapi.yaml post /v1/run","href":"/api-reference/runs/create-a-canvas-run"},{"title":"Get run status and results","deprecated":null,"version":null,"openapi":"/openapi.yaml get /v1/run/{run_id}","href":"/api-reference/runs/get-run-status-and-results"}]},{"group":"Canvas","pages":[{"title":"Get canvas DAG","deprecated":null,"version":null,"openapi":"/openapi.yaml get /v1/canvas/{canvas_id}/dag","href":"/api-reference/canvas/get-canvas-dag"},{"title":"Get task tree","deprecated":null,"version":null,"openapi":"/openapi.yaml get /v1/canvas/{canvas_id}/tasks","href":"/api-reference/canvas/get-task-tree"},{"title":"Get a single task","deprecated":null,"version":null,"openapi":"/openapi.yaml get /v1/canvas/{canvas_id}/tasks/{task_id}","href":"/api-reference/canvas/get-a-single-task"}]}]},{"tab":"Spine App","pages":[{"title":"Spine App","href":"/app/what-is-spine"}]}]},"basePath":"","title":"Authentication - Spine Documentation","deploymentId":"dpl_QQ3G2kinQNQFFK6Sh8dmX2teK74w","buildId":"dpl_QQ3G2kinQNQFFK6Sh8dmX2teK74w","dynamics":[],"chunks":[]}