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

# प्रमाणीकरण

> अपनी API key के साथ YoukaClient कॉन्फ़िगर करें

SDK हर अनुरोध को bearer API key के साथ प्रमाणीकृत करता है। आप एक बार `YoukaClient` बनाते हैं और अपनी प्रक्रिया की पूरी अवधि तक उसे पुन: उपयोग करते हैं।

## `new YoukaClient(options)`

```ts theme={null}
import { YoukaClient } from "@youka/hi/sdk";

const client = new YoukaClient({
  apiKey: process.env.YOUKA_API_KEY!,
});
```

### विकल्प

<ParamField path="apiKey" type="string" required>
  आपकी Youka API key। इसे
  [online.youka.io/account](https://online.youka.io/account) पर **API keys** के अंतर्गत बनाएं।
</ParamField>

<ParamField path="fetch" type="typeof fetch">
  कस्टम `fetch` इम्प्लीमेंटेशन। डिफ़ॉल्ट रूप से ग्लोबल `fetch` होता है। इसका उपयोग
  लॉगिंग, प्रॉक्सी, या कस्टम रिट्राई मिडलवेयर इंजेक्ट करने के लिए करें।
</ParamField>

## API key को स्टोर करना

<Warning>
  API keys आपके बिलिंग तक पहुँच देती हैं। इन्हें कभी भी source control में commit न करें।
</Warning>

अनुशंसित पैटर्न:

<Tabs>
  <Tab title="Environment variable">
    ```ts theme={null}
    const client = new YoukaClient({
      apiKey: process.env.YOUKA_API_KEY!,
    });
    ```
  </Tab>

  <Tab title="Secret manager">
    ```ts theme={null}
    import { getSecret } from "./my-secret-manager";

    const client = new YoukaClient({
      apiKey: await getSecret("youka-api-key"),
    });
    ```
  </Tab>
</Tabs>

## कस्टम fetch इंजेक्ट करना

हर SDK मेथड constructor में दिए गए `fetch` का उपयोग करता है। इससे लॉगिंग या मिडलवेयर जोड़ना आसान हो जाता है:

```ts theme={null}
import { YoukaClient } from "@youka/hi/sdk";

const instrumentedFetch: typeof fetch = async (input, init) => {
  const start = Date.now();
  const response = await fetch(input, init);
  console.log(
    `${init?.method ?? "GET"} ${input} ${response.status} in ${Date.now() - start}ms`,
  );
  return response;
};

const client = new YoukaClient({
  apiKey: process.env.YOUKA_API_KEY!,
  fetch: instrumentedFetch,
});
```

## प्रति-रिक्वेस्ट विकल्प

हर मेथड एक वैकल्पिक दूसरा या तीसरा आर्ग्युमेंट स्वीकार करता है, जिसमें request-level विकल्प होते हैं:

```ts theme={null}
await client.projects.create(body, {
  idempotencyKey: "import-2026-04-08-song-001",
  signal: abortController.signal,
});
```

<ParamField path="idempotencyKey" type="string">
  `Idempotency-Key` हेडर के रूप में पास किया जाता है। उसी key को उसी
  payload के साथ पुन: उपयोग करने पर डुप्लिकेट बनाने के बजाय मूल परिणाम लौटाया जाता है। देखें [API
  idempotency](/hi/api/idempotency).
</ParamField>

<ParamField path="signal" type="AbortSignal">
  मानक abort signal। in-flight requests और लंबे समय तक चलने वाले
  `client.tasks.wait(...)`, `client.projects.wait(...)`, और
  `client.exports.wait(...)` polls को रद्द करता है।
</ParamField>

## आगे क्या

* [Projects](/hi/sdk/projects) — अपना पहला प्रोजेक्ट बनाएं
* [Errors](/hi/sdk/errors) — प्रमाणीकरण विफलताओं को संभालें
* [API authentication](/hi/api/authentication) — raw HTTP header विवरण
