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

# 프로바이더 (BYOK)

> SessionRpc로 세션 단위 프로바이더(BYOK)를 다루는 사용 예시입니다.

## 프로바이더 (BYOK)

대상: SessionRpc (Session에 연결된 세션 단위 작업)

RPC 전체 개요와 페이지 목록은 [RPC](https://kawax.biz/ko/packages/laravel-copilot-sdk/rpc.md)를 참조하세요.

```php theme={null}
// provider: 세션이 사용 중인 프로바이더의 엔드포인트 정보를 가져온다 (experimental)
// BYOK(Bring Your Own Key) 구성에서 LLM 백엔드를 직접 호출할 때 사용
use Revolution\Copilot\Types\Rpc\ProviderGetEndpointRequest;

$endpoint = $session->rpc()->provider()->getEndpoint();
// $endpoint->baseUrl - LLM 클라이언트 라이브러리에 전달할 기본 URL
// $endpoint->type - 프로바이더 종류(openai, anthropic 등)
// $endpoint->headers - 요청에 포함할 HTTP 헤더
// $endpoint->apiKey - 인증 정보(nullable)
// $endpoint->sessionToken - 수명이 짧은 세션 인증 정보(nullable)
// $endpoint->wireApi - 프로바이더 고유의 와이어 API(nullable)

// 선택 중인 모델의 프로바이더 구성 상태 가져오기(자격 증명 검증이나 프로바이더와의 통신은 하지 않음) (experimental)
$status = $session->rpc()->provider()->getStatus();
// $status->hasCustomProvider - GitHub 인증 대신 커스텀 프로바이더를 사용하고 있는지 여부

// 특정 모델의 엔드포인트 가져오기
$endpoint = $session->rpc()->provider()->getEndpoint(
    new ProviderGetEndpointRequest(model: 'gpt-5')
);

// provider: 세션 내 프로바이더 연결 설정을 갱신 (experimental)
$session->rpc()->provider()->updateProvider([
    'provider' => ['name' => 'example', 'baseUrl' => 'https://example.com/v1'],
]);

// provider: 세션 내 모델 하나를 provider와 id로 지정해 갱신 (experimental)
$session->rpc()->provider()->updateModel([
    'model' => ['provider' => 'example', 'id' => 'model', 'maxOutputTokens' => 4096],
]);
// 둘 다 저장된 설정이나 다른 모델을 변경하지 않습니다.
// updateProvider는 기존 인증 정보를 유지하며, 인증 정보나 커스텀 헤더는 받지 않습니다.
// 배열 대신 SessionProviderUpdateProviderRequest / SessionProviderUpdateModelRequest도 사용할 수 있습니다.

// provider: 호스트 관리 모델을 BYOK 레지스트리에서 철회 (experimental)
$result = $session->rpc()->provider()->withdraw(['models' => ['provider/model']]);
// $result->withdrawn, $result->providersRemoved, $result->modelDeselected
```


## Related topics

- [커스텀 프로바이더](https://kawax.biz/ko/packages/laravel-copilot-sdk/custom-providers.md)
- [서비스 프로바이더](https://kawax.biz/ko/service-providers.md)
- [지연 서비스 프로바이더](https://kawax.biz/ko/advanced/deferred-provider.md)
- [AI SDK의 커스텀 프로바이더 만들기](https://kawax.biz/ko/advanced/ai-sdk-custom-provider.md)
- [요청 라이프사이클](https://kawax.biz/ko/lifecycle.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.