[{"data":1,"prerenderedAt":676},["ShallowReactive",2],{"navigation_docs":3,"-cookbook-anthropic-messages":388,"-cookbook-anthropic-messages-surround":671},[4,82,147,173,202,259,298,355],{"title":5,"icon":6,"redirect":7,"path":8,"stem":9,"children":10,"page":73},"Start","i-lucide-compass","\u002Fintro\u002Fquickstart","\u002Fintro","1.intro",[11,14,18,22,74,78],{"title":12,"path":7,"stem":13},"Quickstart","1.intro\u002F0.quickstart",{"title":15,"path":16,"stem":17},"Pipeline Applications","\u002Fintro\u002Fpipeline-app-walkthrough","1.intro\u002F1.pipeline-app-walkthrough",{"title":19,"path":20,"stem":21},"How Redgold works","\u002Fintro\u002Foverview","1.intro\u002F2.overview",{"title":23,"icon":24,"visibility":25,"redirect":26,"path":27,"stem":28,"children":29,"page":73},"Comparison","i-lucide-scale","private","\u002Fintro\u002Fcomparison\u002Fpositioning","\u002Fintro\u002Fcomparison","1.intro\u002F3.comparison",[30,33,37,41,45,49,53,57,61,65,69],{"title":31,"path":26,"stem":32},"Positioning","1.intro\u002F3.comparison\u002F1.positioning",{"title":34,"path":35,"stem":36},"vs Lovable","\u002Fintro\u002Fcomparison\u002Fvs-lovable","1.intro\u002F3.comparison\u002F10.vs-lovable",{"title":38,"path":39,"stem":40},"vs Cloudflare OS","\u002Fintro\u002Fcomparison\u002Fvs-cloudflare-os","1.intro\u002F3.comparison\u002F11.vs-cloudflare-os",{"title":42,"path":43,"stem":44},"vs a backend-as-a-service","\u002Fintro\u002Fcomparison\u002Fvs-baas","1.intro\u002F3.comparison\u002F2.vs-baas",{"title":46,"path":47,"stem":48},"vs serverless compute","\u002Fintro\u002Fcomparison\u002Fvs-serverless-compute","1.intro\u002F3.comparison\u002F3.vs-serverless-compute",{"title":50,"path":51,"stem":52},"vs a do-it-yourself data stack","\u002Fintro\u002Fcomparison\u002Fvs-diy-data-stack","1.intro\u002F3.comparison\u002F4.vs-diy-data-stack",{"title":54,"path":55,"stem":56},"vs Rama","\u002Fintro\u002Fcomparison\u002Fvs-rama","1.intro\u002F3.comparison\u002F5.vs-rama",{"title":58,"path":59,"stem":60},"vs Apache Spark","\u002Fintro\u002Fcomparison\u002Fvs-spark","1.intro\u002F3.comparison\u002F6.vs-spark",{"title":62,"path":63,"stem":64},"vs Apache DataFusion","\u002Fintro\u002Fcomparison\u002Fvs-datafusion","1.intro\u002F3.comparison\u002F7.vs-datafusion",{"title":66,"path":67,"stem":68},"vs Heroku","\u002Fintro\u002Fcomparison\u002Fvs-heroku","1.intro\u002F3.comparison\u002F8.vs-heroku",{"title":70,"path":71,"stem":72},"vs AI model providers","\u002Fintro\u002Fcomparison\u002Fvs-ai-providers","1.intro\u002F3.comparison\u002F9.vs-ai-providers",false,{"title":75,"path":76,"stem":77},"Common tasks","\u002Fintro\u002Fstarting-points","1.intro\u002F4.starting-points",{"title":79,"path":80,"stem":81},"FAQ","\u002Fintro\u002Ffaq","1.intro\u002F5.faq",{"title":83,"icon":84,"redirect":85,"path":86,"stem":87,"children":88,"page":73},"Examples","i-lucide-chef-hat","\u002Fcookbook\u002Foverview","\u002Fcookbook","10.cookbook",[89,91,95,99,103,107,111,115,119,123,127,131,135,139,143],{"title":83,"path":85,"stem":90},"10.cookbook\u002F1.overview",{"title":92,"path":93,"stem":94},"One-shot task in CI","\u002Fcookbook\u002Fone-shot-ci","10.cookbook\u002F10.one-shot-ci",{"title":96,"path":97,"stem":98},"Rate-limit retries","\u002Fcookbook\u002Fretry-rate-limits","10.cookbook\u002F11.retry-rate-limits",{"title":100,"path":101,"stem":102},"Connect GitHub review automation","\u002Fcookbook\u002Fconnect-github-app","10.cookbook\u002F12.connect-github-app",{"title":104,"path":105,"stem":106},"Delegate a task to another agent","\u002Fcookbook\u002Fdelegate-agent-task","10.cookbook\u002F13.delegate-agent-task",{"title":108,"path":109,"stem":110},"Validate a pipeline application change","\u002Fcookbook\u002Fvalidate-pipeline-app","10.cookbook\u002F14.validate-pipeline-app",{"title":112,"path":113,"stem":114},"Verify a managed application deployment","\u002Fcookbook\u002Fverify-managed-deploy","10.cookbook\u002F15.verify-managed-deploy",{"title":116,"path":117,"stem":118},"First API call","\u002Fcookbook\u002Ffirst-api-call","10.cookbook\u002F2.first-api-call",{"title":120,"path":121,"stem":122},"Python client","\u002Fcookbook\u002Fmodel-api-python","10.cookbook\u002F3.model-api-python",{"title":124,"path":125,"stem":126},"Anthropic Messages","\u002Fcookbook\u002Fanthropic-messages","10.cookbook\u002F4.anthropic-messages",{"title":128,"path":129,"stem":130},"Check credits","\u002Fcookbook\u002Fcheck-credits","10.cookbook\u002F5.check-credits",{"title":132,"path":133,"stem":134},"Query data via MCP","\u002Fcookbook\u002Fmcp-query-data","10.cookbook\u002F6.mcp-query-data",{"title":136,"path":137,"stem":138},"Drive an agent via MCP","\u002Fcookbook\u002Fmcp-drive-agent","10.cookbook\u002F7.mcp-drive-agent",{"title":140,"path":141,"stem":142},"Install the client","\u002Fcookbook\u002Finstall-client","10.cookbook\u002F8.install-client",{"title":144,"path":145,"stem":146},"Use another API host","\u002Fcookbook\u002Fpoint-client-at-host","10.cookbook\u002F9.point-client-at-host",{"title":148,"icon":149,"redirect":150,"path":151,"stem":152,"children":153,"page":73},"Agent operations","i-lucide-network","\u002Ffleet\u002Foverview","\u002Ffleet","11.fleet",[154,157,161,165,169],{"title":155,"path":150,"stem":156},"Running agent work","11.fleet\u002F0.overview",{"title":158,"path":159,"stem":160},"Workstreams and issues","\u002Ffleet\u002Fworkstreams-and-issues","11.fleet\u002F1.workstreams-and-issues",{"title":162,"path":163,"stem":164},"Agent lifecycle","\u002Ffleet\u002Fagent-lifecycle","11.fleet\u002F2.agent-lifecycle",{"title":166,"path":167,"stem":168},"Supervision and recovery","\u002Ffleet\u002Fsupervision","11.fleet\u002F3.supervision",{"title":170,"path":171,"stem":172},"An application workstream from request to delivery","\u002Ffleet\u002Fapplication-workstream","11.fleet\u002F4.application-workstream",{"title":174,"icon":175,"redirect":176,"path":177,"stem":178,"children":179,"page":73},"Architecture","i-lucide-layers","\u002Finfrastructure\u002Foverview","\u002Finfrastructure","3.infrastructure",[180,182,186,190,194,198],{"title":174,"path":176,"stem":181},"3.infrastructure\u002F0.overview",{"title":183,"path":184,"stem":185},"A request through the platform","\u002Finfrastructure\u002Frequest-path","3.infrastructure\u002F11.request-path",{"title":187,"path":188,"stem":189},"Agent work and durable state","\u002Finfrastructure\u002Fagent-work","3.infrastructure\u002F12.agent-work",{"title":191,"path":192,"stem":193},"Data and pipelines","\u002Finfrastructure\u002Fdata","3.infrastructure\u002F3.data",{"title":195,"path":196,"stem":197},"AI and agents","\u002Finfrastructure\u002Fai","3.infrastructure\u002F4.ai",{"title":199,"path":200,"stem":201},"Managed deployment","\u002Finfrastructure\u002Fdeployment","3.infrastructure\u002F7.deployment",{"title":203,"icon":204,"redirect":205,"path":206,"stem":207,"children":208,"page":73},"API","i-lucide-book-marked","\u002Freference\u002Fauthentication","\u002Freference","4.reference",[209,212,216,220,224,228,232,236,240,244,248],{"title":210,"path":205,"stem":211},"Authentication","4.reference\u002F1.authentication",{"title":213,"path":214,"stem":215},"Security disclosure policy","\u002Freference\u002Fsecurity-disclosure","4.reference\u002F11.security-disclosure",{"title":217,"path":218,"stem":219},"Model API","\u002Freference\u002Fllm-api","4.reference\u002F2.llm-api",{"title":221,"path":222,"stem":223},"MCP server","\u002Freference\u002Fmcp","4.reference\u002F2.mcp",{"title":225,"path":226,"stem":227},"Data platform preview","\u002Freference\u002Fdata-platform-preview","4.reference\u002F3.data-platform-preview",{"title":229,"path":230,"stem":231},"Terminal client","\u002Freference\u002Fcli","4.reference\u002F6.cli",{"title":233,"path":234,"stem":235},"Pipeline manifest preview","\u002Freference\u002Fpipeline-preview","4.reference\u002F7.pipeline-preview",{"title":237,"path":238,"stem":239},"Limits and retries","\u002Freference\u002Flimits","4.reference\u002F8.limits",{"title":241,"path":242,"stem":243},"API contract details","\u002Freference\u002Fapi-contracts","4.reference\u002F9.api-contracts",{"title":245,"path":246,"stem":247},"Errors","\u002Freference\u002Ferrors","4.reference\u002F9.errors",{"title":249,"icon":250,"visibility":251,"path":252,"stem":253,"children":254,"page":73},"Public API","i-lucide-route","public","\u002Freference\u002Froutes","4.reference\u002Froutes",[255],{"title":256,"path":257,"stem":258},"V1 routes","\u002Freference\u002Froutes\u002Fv1","4.reference\u002Froutes\u002Fv1",{"title":260,"icon":261,"visibility":25,"redirect":262,"path":263,"stem":264,"children":265,"page":73},"Develop","i-lucide-code","\u002Fdevelop\u002Fpipeline-apps\u002Foverview","\u002Fdevelop","5.develop",[266,270,286,290,294],{"title":267,"path":268,"stem":269},"Author a batch transform","\u002Fdevelop\u002Fauthor-a-batch-transform","5.develop\u002F10.author-a-batch-transform",{"title":271,"visibility":251,"redirect":262,"path":272,"stem":273,"children":274,"page":73},"Pipeline Apps","\u002Fdevelop\u002Fpipeline-apps","5.develop\u002F11.pipeline-apps",[275,278,282],{"title":276,"path":262,"stem":277},"Pipeline apps","5.develop\u002F11.pipeline-apps\u002F1.overview",{"title":279,"path":280,"stem":281},"Collaborative board walkthrough","\u002Fdevelop\u002Fpipeline-apps\u002Fcollaborative-board","5.develop\u002F11.pipeline-apps\u002F2.collaborative-board",{"title":283,"path":284,"stem":285},"Release and security lifecycle","\u002Fdevelop\u002Fpipeline-apps\u002Frelease-lifecycle","5.develop\u002F11.pipeline-apps\u002F3.release-lifecycle",{"title":287,"path":288,"stem":289},"Build a vertical","\u002Fdevelop\u002Fbuild-a-vertical","5.develop\u002F5.build-a-vertical",{"title":291,"path":292,"stem":293},"Managed application artifacts","\u002Fdevelop\u002Fscaffold-a-narrow-app","5.develop\u002F7.scaffold-a-narrow-app",{"title":295,"path":296,"stem":297},"Import your data","\u002Fdevelop\u002Fimport-your-data","5.develop\u002F8.import-your-data",{"title":299,"icon":300,"redirect":301,"path":302,"stem":303,"children":304,"page":73},"Guides","i-lucide-layout-grid","\u002Fapplications\u002Fai-agents\u002Foverview","\u002Fapplications","7.applications",[305,309,329,341],{"title":306,"path":307,"stem":308},"Application maturity catalog","\u002Fapplications\u002Fcatalog","7.applications\u002F0.catalog",{"title":310,"visibility":251,"path":311,"stem":312,"children":313,"page":73},"AI Agents","\u002Fapplications\u002Fai-agents","7.applications\u002F1.ai-agents",[314,317,321,325],{"title":315,"path":301,"stem":316},"Coding agents","7.applications\u002F1.ai-agents\u002F01.overview",{"title":318,"path":319,"stem":320},"GitHub App automation","\u002Fapplications\u002Fai-agents\u002Fgithub-app-automation","7.applications\u002F1.ai-agents\u002F04.github-app-automation",{"title":322,"path":323,"stem":324},"agent-cli assistance","\u002Fapplications\u002Fai-agents\u002Fagent-cli-assistance","7.applications\u002F1.ai-agents\u002F05.agent-cli-assistance",{"title":326,"path":327,"stem":328},"Agent REST control","\u002Fapplications\u002Fai-agents\u002Frest-agent-control","7.applications\u002F1.ai-agents\u002F06.rest-agent-control",{"title":330,"visibility":251,"path":331,"stem":332,"children":333,"page":73},"Tickets","\u002Fapplications\u002Ftickets","7.applications\u002F2.tickets",[334,337],{"title":330,"path":335,"stem":336},"\u002Fapplications\u002Ftickets\u002Foverview","7.applications\u002F2.tickets\u002F01.overview",{"title":338,"path":339,"stem":340},"API walkthrough","\u002Fapplications\u002Ftickets\u002Fapi-walkthrough","7.applications\u002F2.tickets\u002F02.api-walkthrough",{"title":342,"icon":343,"visibility":251,"path":344,"stem":345,"children":346,"page":73},"Case studies","i-lucide-book-open-check","\u002Fapplications\u002Fcase-studies","7.applications\u002F6.case-studies",[347,351],{"title":348,"path":349,"stem":350},"Case study: owner-scoped tickets","\u002Fapplications\u002Fcase-studies\u002Ftickets","7.applications\u002F6.case-studies\u002F01.tickets",{"title":352,"path":353,"stem":354},"Case study: repository review and correction","\u002Fapplications\u002Fcase-studies\u002Frepository-review","7.applications\u002F6.case-studies\u002F02.repository-review",{"title":356,"icon":357,"redirect":358,"path":359,"stem":360,"children":361,"page":73},"Resources","i-lucide-library","\u002Fresources\u002Fglossary","\u002Fresources","9.resources",[362,365,369,373,377,380,384],{"title":363,"path":358,"stem":364},"Glossary","9.resources\u002F1.glossary",{"title":366,"path":367,"stem":368},"Terms of Service","\u002Fresources\u002Fterms","9.resources\u002F2.terms",{"title":370,"path":371,"stem":372},"Privacy Policy","\u002Fresources\u002Fprivacy","9.resources\u002F3.privacy",{"title":374,"path":375,"stem":376},"Acceptable Use Policy","\u002Fresources\u002Facceptable-use","9.resources\u002F4.acceptable-use",{"title":79,"path":378,"stem":379},"\u002Fresources\u002Ffaq","9.resources\u002F5.faq",{"title":381,"path":382,"stem":383},"Documentation feedback","\u002Fresources\u002Fdocs-feedback","9.resources\u002F6.docs-feedback",{"title":385,"path":386,"stem":387},"Refund and Cancellation Policy","\u002Fresources\u002Frefund-cancellation","9.resources\u002F7.refund-cancellation",{"id":389,"title":390,"access":391,"audience":392,"body":393,"description":662,"extension":663,"last_verified":664,"links":665,"maturity":666,"meta":667,"navigation":668,"path":125,"seo":669,"stem":126,"__hash__":670},"docs\u002F10.cookbook\u002F4.anthropic-messages.md","Use the Anthropic Messages API","api-key","developer",{"type":394,"value":395,"toc":654},"minimark",[396,401,405,409,448,452,479,586,590,593,597,641,645,650],[397,398,400],"h2",{"id":399},"goal","Goal",[402,403,404],"p",{},"Call a Redgold model through the Anthropic Messages API shape on the Redgold model API.",[397,406,408],{"id":407},"prerequisites","Prerequisites",[410,411,412,430,436],"ul",{},[413,414,415,416,420,421,424,425,429],"li",{},"An ",[417,418,419],"code",{},"sk-rg-"," key in ",[417,422,423],{},"REDGOLD_API_KEY"," (see ",[426,427,428],"a",{"href":117},"Create an API key",").",[413,431,432,435],{},[417,433,434],{},"pip install anthropic",".",[413,437,438,439,442,443,424,446,429],{},"A ",[417,440,441],{},"\u002Fv1\u002Fmessages","-family model id from ",[417,444,445],{},"\u002Fv1\u002Fmodels",[426,447,217],{"href":218},[397,449,451],{"id":450},"steps","Steps",[402,453,454,455,458,459,463,464,467,468,470,471,474,475,478],{},"Two details differ from a direct Anthropic call. Set ",[417,456,457],{},"base_url"," to the host ",[460,461,462],"strong",{},"without"," a ",[417,465,466],{},"\u002Fv1"," suffix — the SDK appends ",[417,469,441],{}," itself. And present the key on the ",[417,472,473],{},"Authorization: Bearer"," header, because the model API reads that header, not the ",[417,476,477],{},"x-api-key"," the SDK sends by default.",[480,481,486],"pre",{"className":482,"code":483,"language":484,"meta":485,"style":485},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import os\nfrom anthropic import Anthropic\n\nclient = Anthropic(\n    base_url=\"https:\u002F\u002Fapi.redgold.ai\",\n    api_key=\"unused\",  # the model API reads Authorization, not x-api-key\n    default_headers={\"Authorization\": f\"Bearer {os.environ['REDGOLD_API_KEY']}\"},\n)\n\nwith client.messages.stream(\n    model=\"model-id-from-v1-models\",\n    max_tokens=256,\n    messages=[{\"role\": \"user\", \"content\": \"Hello\"}],\n) as stream:\n    for text in stream.text_stream:\n        print(text, end=\"\")\n","python","",[417,487,488,496,502,509,515,521,527,533,539,544,550,556,562,568,574,580],{"__ignoreMap":485},[489,490,493],"span",{"class":491,"line":492},"line",1,[489,494,495],{},"import os\n",[489,497,499],{"class":491,"line":498},2,[489,500,501],{},"from anthropic import Anthropic\n",[489,503,505],{"class":491,"line":504},3,[489,506,508],{"emptyLinePlaceholder":507},true,"\n",[489,510,512],{"class":491,"line":511},4,[489,513,514],{},"client = Anthropic(\n",[489,516,518],{"class":491,"line":517},5,[489,519,520],{},"    base_url=\"https:\u002F\u002Fapi.redgold.ai\",\n",[489,522,524],{"class":491,"line":523},6,[489,525,526],{},"    api_key=\"unused\",  # the model API reads Authorization, not x-api-key\n",[489,528,530],{"class":491,"line":529},7,[489,531,532],{},"    default_headers={\"Authorization\": f\"Bearer {os.environ['REDGOLD_API_KEY']}\"},\n",[489,534,536],{"class":491,"line":535},8,[489,537,538],{},")\n",[489,540,542],{"class":491,"line":541},9,[489,543,508],{"emptyLinePlaceholder":507},[489,545,547],{"class":491,"line":546},10,[489,548,549],{},"with client.messages.stream(\n",[489,551,553],{"class":491,"line":552},11,[489,554,555],{},"    model=\"model-id-from-v1-models\",\n",[489,557,559],{"class":491,"line":558},12,[489,560,561],{},"    max_tokens=256,\n",[489,563,565],{"class":491,"line":564},13,[489,566,567],{},"    messages=[{\"role\": \"user\", \"content\": \"Hello\"}],\n",[489,569,571],{"class":491,"line":570},14,[489,572,573],{},") as stream:\n",[489,575,577],{"class":491,"line":576},15,[489,578,579],{},"    for text in stream.text_stream:\n",[489,581,583],{"class":491,"line":582},16,[489,584,585],{},"        print(text, end=\"\")\n",[397,587,589],{"id":588},"expected-output","Expected output",[402,591,592],{},"The assistant's reply streamed to stdout token by token.",[397,594,596],{"id":595},"when-it-breaks","When it breaks",[410,598,599,615,630],{},[413,600,601,604,605,607,608,610,611,614],{},[417,602,603],{},"401"," — the key reached the API only as ",[417,606,477],{},". Confirm the ",[417,609,473],{}," header is set in ",[417,612,613],{},"default_headers"," as shown.",[413,616,617,620,621,623,624,626,627,629],{},[417,618,619],{},"404"," on ",[417,622,441],{}," — ",[417,625,457],{}," includes a ",[417,628,466],{}," suffix. Drop it; the SDK adds the path.",[413,631,632,635,636,638,639,435],{},[417,633,634],{},"400"," unknown model — the id is not a ",[417,637,441],{},"-family model for your account. Read one from ",[417,640,445],{},[397,642,644],{"id":643},"source","Source",[402,646,647,649],{},[426,648,217],{"href":218}," (Anthropic Messages).",[651,652,653],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":485,"searchDepth":498,"depth":498,"links":655},[656,657,658,659,660,661],{"id":399,"depth":498,"text":400},{"id":407,"depth":498,"text":408},{"id":450,"depth":498,"text":451},{"id":588,"depth":498,"text":589},{"id":595,"depth":498,"text":596},{"id":643,"depth":498,"text":644},"Point the Anthropic SDK at api.redgold.ai and authenticate with a bearer token instead of x-api-key.","md","2026-08-10",null,"available",{"toc":507,"visibility":251},{"title":124},{"title":390,"description":662},"XBUYNn8Jpj0M9QH8Fm4KqYxx6S2gpROLfJtIBZh4C4g",[672,674],{"title":120,"path":121,"stem":122,"description":673,"children":-1},"Drive \u002Fv1\u002Fchat\u002Fcompletions with the OpenAI SDK pointed at api.redgold.ai.",{"title":128,"path":129,"stem":130,"description":675,"children":-1},"Read \u002Fv1\u002Fcredits so a long run does not fail partway through on a 402.",1789873213246]