> ## 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 키로 YoukaClient를 구성합니다

SDK는 bearer API 키로 모든 요청을 인증합니다. `YoukaClient`는 한 번만 생성하고 프로세스 수명 동안 재사용합니다.

## `new YoukaClient(options)`

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

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

### 옵션

<ParamField path="apiKey" type="string" required>
  Youka API 키입니다.
  **API keys**에서
  [online.youka.io/account](https://online.youka.io/account)에서 생성하세요.
</ParamField>

<ParamField path="fetch" type="typeof fetch">
  사용자 정의 `fetch` 구현입니다. 기본값은 전역 `fetch`입니다. 로깅, 프록시, 또는 사용자 정의 재시도 미들웨어를 주입하는 데 사용하세요.
</ParamField>

## API 키 저장

<Warning>
  API 키는 결제에 대한 접근 권한을 부여합니다. 소스 컨트롤에 절대 커밋하지 마세요.
</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 메서드는 생성자에 전달한 `fetch`를 사용합니다. 덕분에 로깅이나 미들웨어를 쉽게 추가할 수 있습니다:

```ts theme={null}
import { YoukaClient } from "@youka/ko/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,
});
```

## 요청별 옵션

모든 메서드는 요청 수준 옵션을 담은 선택적 두 번째 또는 세 번째 인자를 받습니다:

```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` 헤더로 전달됩니다. 동일한 키를 동일한 페이로드와 함께 재사용하면 중복을 생성하는 대신 원래 결과를 반환합니다. [API
  idempotency](/ko/api/idempotency)를 참고하세요.
</ParamField>

<ParamField path="signal" type="AbortSignal">
  표준 중단 신호입니다. 진행 중인 요청과 장시간 실행되는
  `client.tasks.wait(...)`, `client.projects.wait(...)`, 그리고
  `client.exports.wait(...)` 폴링을 취소합니다.
</ParamField>

## 다음 단계

* [Projects](/ko/sdk/projects) — 첫 프로젝트 만들기
* [Errors](/ko/sdk/errors) — 인증 실패 처리
* [API authentication](/ko/api/authentication) — 원시 HTTP 헤더 세부 정보
