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

# AI SDK - Aihubmix 공급자

> AI SDK에서 Aihubmix를 대규모 모델 공급자로 사용하여 하나의 키로 방대한 모델에 액세스하세요.

## 지원 기능

Aihubmix 공급자는 다음과 같은 AI 기능을 지원하여 귀하의 제품이 더 이상 LLM 기반에만 국한되지 않도록 합니다:

* **텍스트 생성**: 다양한 모델을 사용하여 텍스트 콘텐츠 생성
* **스트리밍 텍스트**: 실시간 텍스트 스트리밍
* **이미지 생성**: 텍스트 프롬프트에서 이미지 생성
* **벡터 임베딩**: 단일 및 배치 텍스트 임베딩
* **객체 생성**: 구조화된 데이터 생성
* **스트리밍 객체**: 실시간 구조화된 데이터 스트리밍
* **음성 합성**: 텍스트를 음성으로 변환
* **음성-텍스트 변환**: 음성을 텍스트로 변환
* **도구**: 인터넷 검색 및 기타 도구

## 설치

Aihubmix는 `@aihubmix/ai-sdk-provider` 모듈에서 사용할 수 있습니다. `@aihubmix/ai-sdk-provider`를 통해 설치하세요:

<CodeGroup>
  ```bash ai 4.3 theme={null}
  npm i @aihubmix/ai-sdk-provider@0.0.1
  ```

  ```bash ai 5 beta theme={null}
  npm i @aihubmix/ai-sdk-provider
  ```
</CodeGroup>

## 공급자 인스턴스

`@aihubmix/ai-sdk-provider`에서 기본 공급자 인스턴스인 `aihubmix`를 가져올 수 있습니다:

```ts theme={null}
import { aihubmix } from '@aihubmix/ai-sdk-provider';
```

## 구성

안전한 읽기를 위해 Aihubmix API 키를 환경 변수로 설정하세요:

```bash theme={null}
export AIHUBMIX_API_KEY="your-api-key-here"
```

또는 공급자에게 직접 전달하세요:

```ts theme={null}
import { createAihubmix } from '@aihubmix/ai-sdk-provider';

const aihubmix = createAihubmix({
  apiKey: 'your-api-key-here',
});
```

## 사용법

필요한 함수를 가져옵니다:

```ts theme={null}
import { createAihubmix } from '@aihubmix/ai-sdk-provider';
import { 
  generateText, 
  streamText, 
  generateImage, 
  embed, 
  embedMany, 
  generateObject, 
  streamObject, 
  generateSpeech, 
  transcribe 
} from 'ai';
import { z } from 'zod';
```

다양한 유형의 AI 생성 호출 예시:

<CodeGroup>
  ```ts 텍스트 생성 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { generateText } from 'ai';

  const { text } = await generateText({
    model: aihubmix('o4-mini'),
    prompt: '4인용 채식 라자냐 레시피를 작성해 주세요.',
  });
  ```

  ```ts Claude 모델 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { generateText } from 'ai';

  const { text } = await generateText({
    model: aihubmix('claude-3-7-sonnet-20250219'),
    prompt: '양자 컴퓨팅을 쉬운 용어로 설명해 주세요.',
  });
  ```

  ```ts Gemini 모델 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { generateText } from 'ai';

  const { text } = await generateText({
    model: aihubmix('gemini-2.5-flash'),
    prompt: '숫자 목록을 정렬하는 Python 스크립트를 만들어 주세요.',
  });
  ```

  ```ts 스트리밍 텍스트 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { streamText } from 'ai';

  const result = streamText({
    model: aihubmix('gpt-3.5-turbo'),
    prompt: '그림 그리기를 배우는 로봇에 대한 짧은 이야기를 써 주세요.',
    maxOutputTokens: 256,
    temperature: 0.3,
    maxRetries: 3,
  });

  let fullText = '';
  for await (const textPart of result.textStream) {
    fullText += textPart;
    process.stdout.write(textPart);
  }

  console.log('\n사용량:', await result.usage);
  console.log('완료 이유:', await result.finishReason);
  ```

  ```ts 객체 생성 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { generateObject } from 'ai';
  import { z } from 'zod';

  const result = await generateObject({
    model: aihubmix('gpt-4o-mini'),
    schema: z.object({
      recipe: z.object({
        name: z.string(),
        ingredients: z.array(
          z.object({
            name: z.string(),
            amount: z.string(),
          }),
        ),
        steps: z.array(z.string()),
      }),
    }),
    prompt: '라자냐 레시피를 생성해 주세요.',
  });

  console.log(JSON.stringify(result.object.recipe, null, 2));
  console.log('토큰 사용량:', result.usage);
  console.log('완료 이유:', result.finishReason);
  ```

  ```ts 스트리밍 객체 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { streamObject } from 'ai';
  import { z } from 'zod';

  const result = await streamObject({
    model: aihubmix('gpt-4o-mini'),
    schema: z.object({
      recipe: z.object({
        name: z.string(),
        ingredients: z.array(
          z.object({
            name: z.string(),
            amount: z.string(),
          }),
        ),
        steps: z.array(z.string()),
      }),
    }),
    prompt: '라자냐 레시피를 생성해 주세요.',
  });

  for await (const objectPart of result.partialObjectStream) {
    console.log(objectPart);
  }

  console.log('토큰 사용량:', result.usage);
  console.log('최종 객체:', result.object);
  ```

  ```ts 도구 호출 theme={null}
  // Aihubmix 공급자는 웹 검색을 포함한 다양한 도구를 지원합니다:
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { generateText } from 'ai';

  const { text } = await generateText({
    model: aihubmix('gpt-4'),
    prompt: 'AI의 최신 발전은 무엇인가요?',
    tools: {
      webSearchPreview: aihubmix.tools.webSearchPreview({
        searchContextSize: 'high',
      }),
    },
  });
  ```

  ```ts 이미지 생성 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { generateImage } from 'ai';

  const { image } = await generateImage({
    model: aihubmix.image('gpt-image-1'),
    prompt: '산속의 아름다운 일몰',
  });
  ```

  ```ts 음성 합성 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { generateSpeech } from 'ai';

  const { audio } = await generateSpeech({
    model: aihubmix.speech('tts-1'),
    text: '안녕하세요, 이것은 음성 합성 테스트입니다.',
  });

  // 오디오 파일 저장
  await saveAudioFile(audio);
  console.log('오디오 생성 성공:', audio);
  ```

  ```ts 음성-텍스트 변환 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { transcribe } from 'ai';

  const { text } = await transcribe({
    model: aihubmix.transcription('whisper-1'),
    audio: audioFile,
  });
  ```

  ```ts 벡터 임베딩 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { embed } from 'ai';

  const { embedding } = await embed({
    model: aihubmix.embedding('text-embedding-ada-002'),
    value: '안녕하세요, 세계!',
  });
  ```

  ```ts 배치 임베딩 theme={null}
  import { aihubmix } from '@aihubmix/ai-sdk-provider';
  import { embedMany } from 'ai';

  const { embeddings, usage } = await embedMany({
    model: aihubmix.embedding('text-embedding-3-small'),
    values: [
      '해변의 맑은 날',
      '도시의 비 오는 오후',
      '산속의 눈 오는 밤',
    ],
  });

  console.log('임베딩 벡터:', embeddings);
  console.log('사용량:', usage);
  ```
</CodeGroup>

## 관련 자료:

* [Aihubmix provider](https://v5.ai-sdk.dev/providers/community-providers/aihubmix)
* [AI SDK](https://ai-sdk.dev/docs)

***

마지막 업데이트: 2026-06-01
