> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexinference.com/llms.txt
> Use this file to discover all available pages before exploring further.

# क्लाउड कोड

> डेडलाइन वाली एजेंट key के साथ क्लाउड कोड को FlexInference पर पॉइंट करें।

क्लाउड कोड Anthropic Messages API का उपयोग करता है। हम उस API को `POST /v1/messages` पर चलाते हैं, इसलिए एक base URL और एक key ही पूरा इंटीग्रेशन है।

क्लाउड कोड में `start_within` सेट करने का कोई विकल्प नहीं है, इसलिए डेडलाइन key पर जाती है। पहले एक बनाएं (देखें [agent keys](/hi/agent-keys))।

तीन से दस मिनट की अवधि में, बिना streaming के, managed keys पर क्लाउड का सस्ता tier काम करता है। एक इंटरैक्टिव सेशन stream करता है, इसलिए यहां एक tier चुनें। एक key duration दोनों ही तरीकों से काम करती है, क्योंकि यह विफल होने के बजाय एक tier पर वापस आ जाती है। देखें [Claude durations need a longer window](/hi/deadline-routing)।

शुरू करने से पहले आपके संगठन को Anthropic चलाने में सक्षम होना चाहिए। आपकी अपनी keys पर इसका मतलब है **Provider keys** टैब पर एक Anthropic provider key, क्योंकि हम inference को दोबारा नहीं बेचते हैं। [Managed Keys](/hi/billing) पर इसका मतलब है Anthropic चालू और वित्तपोषित।

## इसे एक एजेंट के साथ सेट करें

नीचे दिए गए ब्लॉक को खोलें और इसे किसी भी कोडिंग एजेंट में कॉपी करें। प्रॉम्प्ट कभी भी आपकी API key नहीं मांगता है: एजेंट बाकी सब कुछ कॉन्फ़िगर करता है, फिर आपके लिए चलाने के लिए एक export लाइन प्रिंट करता है।

<Accordion title="एजेंट सेटअप प्रॉम्प्ट कॉपी करें">
  ```text theme={null}
  Configure Claude Code to send its requests to FlexInference, which serves the Anthropic Messages API.

  You will never see or handle my API key. Claude Code reads it from the `ANTHROPIC_AUTH_TOKEN` environment variable, and I export that myself. Do not ask me for the key, do not write it into any file, and do not read it from my environment.

  Ask me whether to configure this globally or for one project, then edit `~/.claude/settings.json` or `.claude/settings.json` accordingly. Create the file if it does not exist, and preserve every setting already in it.

  Add this `env` block, merging into any existing `env` rather than replacing it. Note that it carries no credential:

  {
    "env": {
      "ANTHROPIC_BASE_URL": "https://api.flexinference.com",
      "ANTHROPIC_MODEL": "claude-opus-5",
      "ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5",
      "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
    }
  }

  Then print this line for me to run in the shell I start Claude Code from. Do not run it and do not ask for the value:

  export ANTHROPIC_AUTH_TOKEN=<paste your key here>

  Rules that matter, do not deviate:
  - `ANTHROPIC_BASE_URL` must NOT end in `/v1`. Claude Code appends `/v1/messages` itself.
  - The credential must arrive as `ANTHROPIC_AUTH_TOKEN`, never `ANTHROPIC_API_KEY`. The first sends `Authorization: Bearer`, which FlexInference requires. The second sends `x-api-key`, which it refuses with `401 missing_api_key`.
  - Both model variables must be `claude-*` slugs. Claude Code sends Anthropic-native fields such as `output_config` on every request, and FlexInference refuses to mistranslate them onto a non-Claude model.
  - `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` must be `"1"`. Without it Claude Code sends experimental beta fields such as `context_management`, FlexInference does not forward the `anthropic-beta` headers they need, and every request fails with `400 context_management: Extra inputs are not permitted`.
  - Do not add a retry setting. Claude Code retries on its own and my key may carry its own policy.

  Finally, tell me that Anthropic must be servable on my FlexInference organization. On BYOK that means an Anthropic provider key on the API, then Provider keys tab. On Managed Keys it means Anthropic enabled and funded. Then start a new Claude Code session and report what you changed.
  ```
</Accordion>

## क्लाउड कोड कॉन्फ़िगर करें

1. `~/.claude/settings.json` बनाएं या खोलें। `.claude/settings.json` पर एक प्रति-प्रोजेक्ट फ़ाइल भी इसी तरह काम करती है।
2. router, अपनी key और दोनों models का नामकरण करते हुए एक `env` ब्लॉक जोड़ें।

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.flexinference.com",
    "ANTHROPIC_AUTH_TOKEN": "flex_live_...",
    "ANTHROPIC_MODEL": "claude-opus-5",
    "ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}
```

3. क्लाउड कोड शुरू करें।

```bash theme={null}
claude
```

secret को फ़ाइल से बाहर रखने के लिए, इसके बजाय अपने shell में वही variables export करें।

```bash theme={null}
export ANTHROPIC_BASE_URL=https://api.flexinference.com
export ANTHROPIC_AUTH_TOKEN=flex_live_...
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
```

चार नियम इसे काम करते हैं।

**`/v1` प्रत्यय छोड़ दें।** क्लाउड कोड base URL में `/v1/messages` खुद जोड़ता है।

**`ANTHROPIC_AUTH_TOKEN` का उपयोग करें, कभी भी `ANTHROPIC_API_KEY` का नहीं।** पहला `Authorization: Bearer` भेजता है, जिसकी हमें आवश्यकता है। दूसरा `x-api-key` भेजता है, जिसे हम अस्वीकार करते हैं।

**`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` को `1` पर सेट करें।** अन्यथा क्लाउड कोड `context_management` जैसे प्रायोगिक beta फ़ील्ड भेजता है। हम उन फ़ील्ड को आवश्यक `anthropic-beta` हेडर फॉरवर्ड नहीं करते हैं, इसलिए हर अनुरोध विफल हो जाता है।

**दोनों model variables सेट करें।** क्लाउड कोड एक key के विरुद्ध एक बड़ा main-loop model और एक छोटा background model चलाता है। दोनों `claude-*` slugs होने चाहिए।

## पुष्टि करें कि key लागू हो गई है

हर response के साथ `x-flexinference-defaults-applied` आता है। क्लाउड कोड response headers नहीं दिखाता है, इसलिए इसके बजाय डैशबोर्ड में **Logs** के तहत अनुरोध पढ़ें।

## समस्या निवारण

**`400 context_management: Extra inputs are not permitted`।** क्लाउड कोड ने एक प्रायोगिक beta फ़ील्ड भेजा, और हम उसे आवश्यक `anthropic-beta` हेडर फॉरवर्ड नहीं करते हैं। `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` सेट करें और एक नया सेशन शुरू करें। वही फ़्लैग किसी अन्य `Extra inputs are not permitted` अस्वीकृति को साफ़ करता है जो एक beta फ़ील्ड का नाम लेती है।

**[`401 missing_api_key`](/hi/errors#missing_api_key)।** आपने `ANTHROPIC_API_KEY` सेट किया था, इसलिए क्लाइंट ने `x-api-key` भेजा, जिसे हम नहीं पढ़ते हैं। इसके बजाय `ANTHROPIC_AUTH_TOKEN` सेट करें और `ANTHROPIC_API_KEY` को अनसेट करें।

**[`400 unsupported_parameter`](/hi/errors#unsupported_parameter) `output_config` का नामकरण।** एक model variable एक गैर-क्लाउड slug की ओर इशारा करता है, और क्लाउड कोड Anthropic-native फ़ील्ड भेजता है जिन्हें हम गलत अनुवाद करने से मना करते हैं। दोनों model variables को `claude-*` slugs पर सेट करें।

**[`404 unknown_url`](/hi/errors#unknown_url) `/v1/messages/count_tokens` का नामकरण।** हम उस पथ को रूट नहीं करते हैं। एक `claude -p` रन इसे कभी नहीं बुलाता है, हालांकि एक इंटरैक्टिव सेशन कर सकता है।

**हर अनुरोध एक पूर्ण retry बजट खर्च करता है।** क्लाउड कोड अपने आप retries करता है, और एक key `retry` नीति इसके साथ स्टैक करती है। इस क्लाइंट द्वारा उपयोग की जाने वाली key पर `retry` को अनसेट छोड़ दें।

हमारे द्वारा लौटाए गए हर अस्वीकृति के लिए [errors](/hi/errors) देखें, और उन लोगों के लिए [agent keys](/hi/agent-keys) देखें जो क्लाउड कोड के लिए विशिष्ट नहीं हैं।
