콘텐츠로 이동

AI SDK로 어떤 모델이든 사용

기본적으로 Agents SDK는 Responses API 또는 Chat Completions API를 통해 OpenAI 모델과 함께 작동합니다. 그러나 다른 모델을 사용하려면, Vercel’s AI SDK가 제공하는 다양한 지원 모델을 이 어댑터를 통해 Agents SDK에 연결할 수 있습니다.

  1. 확장 패키지를 설치하여 AI SDK 어댑터를 설치합니다:

    Terminal window
    npm install @openai/agents-extensions
  2. Vercel’s AI SDK에서 원하는 모델 패키지를 선택해 설치합니다:

    Terminal window
    npm install @ai-sdk/openai
  3. 어댑터와 모델을 가져와 에이전트에 연결합니다:

    import { openai } from '@ai-sdk/openai';
    import { aisdk } from '@openai/agents-extensions';
  4. 에이전트가 사용할 모델 인스턴스를 초기화합니다:

    const model = aisdk(openai('gpt-5-mini'));
AI SDK Setup
import { Agent, run } from '@openai/agents';
// Import the model package you installed
import { openai } from '@ai-sdk/openai';
// Import the adapter
import { aisdk } from '@openai/agents-extensions';
// Create a model instance to be used by the agent
const model = aisdk(openai('gpt-5-mini'));
// Create an agent with the model
const agent = new Agent({
name: 'My Agent',
instructions: 'You are a helpful assistant.',
model,
});
// Run the agent with the new model
run(agent, 'What is the capital of Germany?');

메시지에 프로바이더별 옵션을 전송해야 하는 경우 providerMetadata를 통해 전달하세요. 값은 기본 AI SDK 모델로 그대로 전달됩니다. 예를 들어, Agents SDK에서 다음과 같은 providerData

providerData: {
anthropic: {
cacheControl: {
type: 'ephemeral';
}
}
}

AI SDK 통합을 사용할 때 다음과 같이 됩니다

providerMetadata: {
anthropic: {
cacheControl: {
type: 'ephemeral';
}
}
}