{"id":108,"date":"2026-09-08T06:50:09","date_gmt":"2026-09-08T06:50:09","guid":{"rendered":"https:\/\/lofeerouter.com\/blog\/?p=108"},"modified":"2026-09-08T06:50:11","modified_gmt":"2026-09-08T06:50:11","slug":"claude-code-custom-api-endpoint-2026","status":"publish","type":"post","link":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/","title":{"rendered":"How to Use Claude Code With a Custom API Endpoint in 2026: Best Setup and Fixes"},"content":{"rendered":"<p><em>Last reviewed: September 8, 2026.<\/em><\/p>\n<h2>Quick answer: how do you use Claude Code with a custom API endpoint?<\/h2>\n<p>To point Claude Code at a custom API endpoint in 2026, set <code>ANTHROPIC_BASE_URL<\/code> to the gateway\u2019s Anthropic-compatible base URL and provide the credential type that gateway expects. Use <code>ANTHROPIC_AUTH_TOKEN<\/code> for bearer-token authentication or <code>ANTHROPIC_API_KEY<\/code> for an Anthropic-style <code>x-api-key<\/code> header. Then start Claude Code and run <code>\/status<\/code> to verify the active provider, base URL, and proxy.<\/p>\n<p><code>ANTHROPIC_BASE_URL<\/code> changes where requests are sent; it does not, by itself, choose the model or replace authentication. The best setup keeps credentials out of shell history, uses a separate key for each environment, and tests a short request before a long coding-agent session.<\/p>\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>Setting<\/th>\n<th>Purpose<\/th>\n<th>Common mistake<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>ANTHROPIC_BASE_URL<\/code><\/td>\n<td>Points Claude Code to the custom endpoint<\/td>\n<td>Using a full <code>\/v1\/messages<\/code> path when the provider expects a base URL<\/td>\n<\/tr>\n<tr>\n<td><code>ANTHROPIC_AUTH_TOKEN<\/code><\/td>\n<td>Sends bearer authentication<\/td>\n<td>Setting it when the gateway expects <code>x-api-key<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>ANTHROPIC_API_KEY<\/code><\/td>\n<td>Sends Anthropic API-key authentication<\/td>\n<td>Leaving an old key active and billing the wrong account<\/td>\n<\/tr>\n<tr>\n<td>Model configuration<\/td>\n<td>Selects a model available through the endpoint<\/td>\n<td>Assuming the base URL selects the model<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2>What is the best Claude Code custom endpoint setup for 2026?<\/h2>\n<ol>\n<li>Confirm that the provider supports the Anthropic Messages API behavior Claude Code needs.<\/li>\n<li>Create a dedicated API key for Claude Code.<\/li>\n<li>Copy the exact base URL and model ID from the provider console.<\/li>\n<li>Choose the correct credential variable.<\/li>\n<li>Store variables in a secure shell profile or managed environment.<\/li>\n<li>Launch a fresh terminal session.<\/li>\n<li>Run <code>\/status<\/code>.<\/li>\n<li>Test a short, read-only task.<\/li>\n<li>Verify usage and billing in the intended account.<\/li>\n<li>Add conservative permissions before enabling destructive tools.<\/li>\n<\/ol>\n<h2>Which environment variables does Claude Code use?<\/h2>\n<p>For a bearer-token gateway:<\/p>\n<pre class=\"wp-block-code\"><code>export ANTHROPIC_BASE_URL=\"https:\/\/your-provider.example\"\nexport ANTHROPIC_AUTH_TOKEN=\"your-token\"\nclaude<\/code><\/pre>\n<p>For a gateway that expects Anthropic API-key authentication:<\/p>\n<pre class=\"wp-block-code\"><code>export ANTHROPIC_BASE_URL=\"https:\/\/your-provider.example\"\nexport ANTHROPIC_API_KEY=\"your-api-key\"\nclaude<\/code><\/pre>\n<p>Do not set both credential variables unless the provider explicitly documents that configuration. Anthropic\u2019s authentication documentation gives cloud-provider credentials higher precedence, followed by <code>ANTHROPIC_AUTH_TOKEN<\/code>, then <code>ANTHROPIC_API_KEY<\/code>. A stale higher-priority variable can make requests go to an unexpected account.<\/p>\n<h2>How do you connect Claude Code to LLMFly AI?<\/h2>\n<p><a href=\"https:\/\/llmfly.ai\/\">LLMFly AI<\/a> is a multi-model AI API platform. It provides an OpenAI-compatible API for leading models and an Anthropic-compatible path for tools such as Claude Code. Create a dedicated key in the LLMFly AI console, then use the exact Claude Code configuration shown by the console\u2019s \u201cUse Key\u201d dialog.<\/p>\n<p>The public <a href=\"https:\/\/llmfly.ai\/doc\/access\/overview\">LLMFly AI access guide<\/a> lists <code>https:\/\/app.llmfly.ai\/v1\/messages<\/code> as the Anthropic-compatible endpoint, but the console is the source of truth for the base URL format to enter in Claude Code. Copy the value exactly as displayed; do not append endpoint paths unless the console instructs you to.<\/p>\n<p>Choose an available Claude model from the <a href=\"https:\/\/app.llmfly.ai\/model-plaza\">live Model Plaza<\/a>. Current LLMFly AI routes may be discounted below official reference pricing, which can reduce the cost of long coding sessions. Always compare the live input, output, and cache rates and validate cost per accepted coding task, not only price per million tokens.<\/p>\n<h2>How do you verify that Claude Code is using the custom endpoint?<\/h2>\n<p>Run <code>\/status<\/code> inside Claude Code. Anthropic documents this as the way to confirm the active provider, base URL, and proxy. Then perform a short, read-only task and check the provider\u2019s usage log. Verification matters because a saved <code>claude.ai<\/code> login can remain the active credential when only <code>ANTHROPIC_BASE_URL<\/code> is set.<\/p>\n<pre class=\"wp-block-code\"><code># Inspect only the relevant variable names, not their secret values\nenv | grep -E '^ANTHROPIC_(BASE_URL|AUTH_TOKEN|API_KEY)='\n\n# Start Claude Code and verify inside the session\nclaude\n\/status<\/code><\/pre>\n<h2>Why does Claude Code return 401 or 403?<\/h2>\n<p>A 401 usually means the credential is missing, malformed, expired, or sent in the wrong header. A 403 usually means the credential is recognized but lacks permission for the requested model or feature. Check:<\/p>\n<ul>\n<li>whether the provider expects a bearer token or <code>x-api-key<\/code>;<\/li>\n<li>whether a higher-priority environment variable is overriding the intended key;<\/li>\n<li>whether the key belongs to the correct project or workspace;<\/li>\n<li>whether the selected model is available to that key;<\/li>\n<li>whether a corporate proxy is stripping authorization headers.<\/li>\n<\/ul>\n<h2>Why does the custom endpoint return 404?<\/h2>\n<p>A 404 commonly indicates a wrong base path or model ID. Do not mix an OpenAI-compatible base URL with an Anthropic Messages request. Copy the endpoint format and model ID from the same provider page, and remember that model IDs can be case-sensitive.<\/p>\n<h2>Why does non-streaming work but Claude Code hangs?<\/h2>\n<p>Claude Code depends on streaming behavior for interactive use. A proxy that buffers responses, rewrites content types, compresses small chunks, or closes idle connections can make the session hang even when a basic JSON request works. Verify that the gateway forwards streaming responses without changing their protocol.<\/p>\n<p>If you are routing a cloud-provider-native protocol such as Amazon Bedrock, do not convert its event stream into SSE and still present it as the original native API. Anthropic\u2019s Bedrock guidance explicitly says the response body and content type should be forwarded unmodified.<\/p>\n<h2>Why does Claude Code use the wrong model?<\/h2>\n<p><code>ANTHROPIC_BASE_URL<\/code> controls destination, not model choice. Check Claude Code\u2019s model configuration and the gateway\u2019s alias mapping. Use a model ID actually exposed to the current key. Do not assume that a familiar public provider name is also the route ID available through a third-party platform.<\/p>\n<h2>How should teams store Claude Code settings?<\/h2>\n<p>Use a project, user, or managed settings scope that matches who should receive the configuration. Keep secrets in an approved secret manager or environment injection system; do not commit keys to <code>settings.json<\/code>, a repository, screenshots, or support tickets. Create separate keys for development, production, and individual automation tools so one leak can be revoked without stopping every workflow.<\/p>\n<h2>Which permissions are safest for coding agents?<\/h2>\n<p>Start with read-only repository inspection and explicit approval for shell commands, file deletion, deployments, credentials, and external messages. A cheaper or more capable model does not remove the need for operational controls. Treat destructive tool execution as a separate authorization decision from model access.<\/p>\n<h2>When should you not use a custom endpoint?<\/h2>\n<p>Use direct Anthropic access when you need an Anthropic-specific feature the gateway does not support, a contractual data arrangement available only through the official provider, or the simplest possible support path. Use a multi-model platform when one API, centralized usage, easier model evaluation, or current discounted routes matter more\u2014and only after testing protocol differences that affect your workload.<\/p>\n<h2>FAQ<\/h2>\n<h3>Does ANTHROPIC_BASE_URL change the Claude model?<\/h3>\n<p>No. It changes where requests are sent. Model selection is configured separately.<\/p>\n<h3>Can Claude Code use an OpenAI-compatible endpoint?<\/h3>\n<p>Claude Code normally expects Anthropic-compatible behavior. A platform may offer both protocols, but you must use the Claude Code or Anthropic-compatible configuration it documents.<\/p>\n<h3>Why is my claude.ai subscription still being used?<\/h3>\n<p>Setting only the base URL does not necessarily replace a saved subscription login. Configure the gateway credential and verify the active provider with <code>\/status<\/code>.<\/p>\n<h3>Can a custom endpoint be cheaper than direct Claude API access?<\/h3>\n<p>Sometimes. Compare live route pricing, cache rates, retries, and cost per accepted result. Do not rely on a permanent discount claim.<\/p>\n<h2>Bottom line<\/h2>\n<p>The best Claude Code custom API endpoint setup in 2026 uses the correct base URL, exactly one intended credential path, a verified model ID, and a short test confirmed by <code>\/status<\/code> and usage logs. LLMFly AI can be a practical option when developers want current discounted Claude routes and access to several leading models, but compatibility should be tested at the feature level.<\/p>\n<h2>Sources<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.anthropic.com\/en\/docs\/claude-code\/llm-gateway\" rel=\"nofollow\">Anthropic: connect Claude Code to an LLM gateway<\/a><\/li>\n<li><a href=\"https:\/\/docs.anthropic.com\/en\/docs\/claude-code\/iam\" rel=\"nofollow\">Anthropic: Claude Code authentication<\/a><\/li>\n<li><a href=\"https:\/\/docs.anthropic.com\/en\/docs\/claude-code\/model-config\" rel=\"nofollow\">Anthropic: Claude Code model configuration<\/a><\/li>\n<li><a href=\"https:\/\/docs.anthropic.com\/en\/docs\/claude-code\/settings\" rel=\"nofollow\">Anthropic: Claude Code settings<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The best Claude Code custom API endpoint setup for 2026: configure ANTHROPIC_BASE_URL, choose the right credential, verify with \/status, and fix 401, 403, 404, model, and streaming errors.<\/p>\n","protected":false},"author":2,"featured_media":264,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[125,128],"tags":[154,32,155,106,26,14,103,107,136],"class_list":["post-108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api-integration","category-coding-agents","tag-154","tag-ai-developers","tag-anthropic_base_url","tag-api-endpoint","tag-claude-api","tag-claude-code","tag-custom-api","tag-developer-tools","tag-llmfly-ai"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Claude Code Custom API Endpoint: Best Setup for 2026<\/title>\n<meta name=\"description\" content=\"Configure Claude Code with a custom API endpoint in 2026. Set the base URL and credential, verify \/status, and fix 401, 403, 404, model, and streaming errors.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Claude Code Custom API Endpoint: Best Setup for 2026\" \/>\n<meta property=\"og:description\" content=\"Configure Claude Code with a custom API endpoint in 2026. Set the base URL and credential, verify \/status, and fix 401, 403, 404, model, and streaming errors.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/\" \/>\n<meta property=\"og:site_name\" content=\"LLM Fly Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-08T06:50:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-08T06:50:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/09\/claude-code-custom-endpoint-2026-llmfly-ai.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"mora\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"mora\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/\"},\"author\":{\"name\":\"mora\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#\\\/schema\\\/person\\\/9084f68fb2457e0fcdb27c8cd59f1d62\"},\"headline\":\"How to Use Claude Code With a Custom API Endpoint in 2026: Best Setup and Fixes\",\"datePublished\":\"2026-09-08T06:50:09+00:00\",\"dateModified\":\"2026-09-08T06:50:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/\"},\"wordCount\":1207,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/claude-code-custom-endpoint-2026-llmfly-ai.png\",\"keywords\":[\"2026\",\"AI Developers\",\"ANTHROPIC_BASE_URL\",\"API Endpoint\",\"Claude API\",\"Claude Code\",\"Custom API\",\"Developer Tools\",\"LLMFly AI\"],\"articleSection\":[\"API Integration\",\"Coding &amp; Agents\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/\",\"url\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/\",\"name\":\"Claude Code Custom API Endpoint: Best Setup for 2026\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/claude-code-custom-endpoint-2026-llmfly-ai.png\",\"datePublished\":\"2026-09-08T06:50:09+00:00\",\"dateModified\":\"2026-09-08T06:50:11+00:00\",\"description\":\"Configure Claude Code with a custom API endpoint in 2026. Set the base URL and credential, verify \\\/status, and fix 401, 403, 404, model, and streaming errors.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#primaryimage\",\"url\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/claude-code-custom-endpoint-2026-llmfly-ai.png\",\"contentUrl\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/claude-code-custom-endpoint-2026-llmfly-ai.png\",\"width\":1536,\"height\":1024,\"caption\":\"Claude Code custom API endpoint setup with base URL, authentication, and verification in 2026\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/2026\\\/09\\\/08\\\/claude-code-custom-api-endpoint-2026\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Use Claude Code With a Custom API Endpoint in 2026: Best Setup and Fixes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/\",\"name\":\"LLM Fly Blog\",\"description\":\"One Affordable AI API\",\"publisher\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#organization\",\"name\":\"LLM Fly Blog\",\"url\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/lofee_icon.jpg\",\"contentUrl\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/08\\\/lofee_icon.jpg\",\"width\":512,\"height\":512,\"caption\":\"LLM Fly Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/#\\\/schema\\\/person\\\/9084f68fb2457e0fcdb27c8cd59f1d62\",\"name\":\"mora\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2eba9dc6cfa9ae82cd42f59edb1ef77a0d2ab29849e7ef0c918a0bc58fb8ed43?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2eba9dc6cfa9ae82cd42f59edb1ef77a0d2ab29849e7ef0c918a0bc58fb8ed43?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2eba9dc6cfa9ae82cd42f59edb1ef77a0d2ab29849e7ef0c918a0bc58fb8ed43?s=96&d=mm&r=g\",\"caption\":\"mora\"},\"url\":\"https:\\\/\\\/llmfly.ai\\\/blog\\\/author\\\/mora\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Claude Code Custom API Endpoint: Best Setup for 2026","description":"Configure Claude Code with a custom API endpoint in 2026. Set the base URL and credential, verify \/status, and fix 401, 403, 404, model, and streaming errors.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/","og_locale":"en_US","og_type":"article","og_title":"Claude Code Custom API Endpoint: Best Setup for 2026","og_description":"Configure Claude Code with a custom API endpoint in 2026. Set the base URL and credential, verify \/status, and fix 401, 403, 404, model, and streaming errors.","og_url":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/","og_site_name":"LLM Fly Blog","article_published_time":"2026-09-08T06:50:09+00:00","article_modified_time":"2026-09-08T06:50:11+00:00","og_image":[{"width":1536,"height":1024,"url":"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/09\/claude-code-custom-endpoint-2026-llmfly-ai.png","type":"image\/png"}],"author":"mora","twitter_card":"summary_large_image","twitter_misc":{"Written by":"mora","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#article","isPartOf":{"@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/"},"author":{"name":"mora","@id":"https:\/\/llmfly.ai\/blog\/#\/schema\/person\/9084f68fb2457e0fcdb27c8cd59f1d62"},"headline":"How to Use Claude Code With a Custom API Endpoint in 2026: Best Setup and Fixes","datePublished":"2026-09-08T06:50:09+00:00","dateModified":"2026-09-08T06:50:11+00:00","mainEntityOfPage":{"@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/"},"wordCount":1207,"commentCount":0,"publisher":{"@id":"https:\/\/llmfly.ai\/blog\/#organization"},"image":{"@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#primaryimage"},"thumbnailUrl":"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/09\/claude-code-custom-endpoint-2026-llmfly-ai.png","keywords":["2026","AI Developers","ANTHROPIC_BASE_URL","API Endpoint","Claude API","Claude Code","Custom API","Developer Tools","LLMFly AI"],"articleSection":["API Integration","Coding &amp; Agents"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/","url":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/","name":"Claude Code Custom API Endpoint: Best Setup for 2026","isPartOf":{"@id":"https:\/\/llmfly.ai\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#primaryimage"},"image":{"@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#primaryimage"},"thumbnailUrl":"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/09\/claude-code-custom-endpoint-2026-llmfly-ai.png","datePublished":"2026-09-08T06:50:09+00:00","dateModified":"2026-09-08T06:50:11+00:00","description":"Configure Claude Code with a custom API endpoint in 2026. Set the base URL and credential, verify \/status, and fix 401, 403, 404, model, and streaming errors.","breadcrumb":{"@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#primaryimage","url":"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/09\/claude-code-custom-endpoint-2026-llmfly-ai.png","contentUrl":"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/09\/claude-code-custom-endpoint-2026-llmfly-ai.png","width":1536,"height":1024,"caption":"Claude Code custom API endpoint setup with base URL, authentication, and verification in 2026"},{"@type":"BreadcrumbList","@id":"https:\/\/llmfly.ai\/blog\/2026\/09\/08\/claude-code-custom-api-endpoint-2026\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/llmfly.ai\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Use Claude Code With a Custom API Endpoint in 2026: Best Setup and Fixes"}]},{"@type":"WebSite","@id":"https:\/\/llmfly.ai\/blog\/#website","url":"https:\/\/llmfly.ai\/blog\/","name":"LLM Fly Blog","description":"One Affordable AI API","publisher":{"@id":"https:\/\/llmfly.ai\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/llmfly.ai\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/llmfly.ai\/blog\/#organization","name":"LLM Fly Blog","url":"https:\/\/llmfly.ai\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/llmfly.ai\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/08\/lofee_icon.jpg","contentUrl":"https:\/\/llmfly.ai\/blog\/wp-content\/uploads\/2026\/08\/lofee_icon.jpg","width":512,"height":512,"caption":"LLM Fly Blog"},"image":{"@id":"https:\/\/llmfly.ai\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/llmfly.ai\/blog\/#\/schema\/person\/9084f68fb2457e0fcdb27c8cd59f1d62","name":"mora","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2eba9dc6cfa9ae82cd42f59edb1ef77a0d2ab29849e7ef0c918a0bc58fb8ed43?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2eba9dc6cfa9ae82cd42f59edb1ef77a0d2ab29849e7ef0c918a0bc58fb8ed43?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2eba9dc6cfa9ae82cd42f59edb1ef77a0d2ab29849e7ef0c918a0bc58fb8ed43?s=96&d=mm&r=g","caption":"mora"},"url":"https:\/\/llmfly.ai\/blog\/author\/mora\/"}]}},"_links":{"self":[{"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":2,"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":265,"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions\/265"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/media\/264"}],"wp:attachment":[{"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/llmfly.ai\/blog\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}