콘텐츠로 이동

AI SDK로 어떤 모델이든 사용

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

  1. extensions 패키지를 설치해 AI SDK 어댑터를 설치합니다:

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

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

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

    const model = aisdk(openai('gpt-5-mini'));
AI SDK 설정
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';
}
}
}