JavaScript / TypeScript SDK
공식 @emini-ai/sdk 클라이언트 — 카테고리별로 하나의 클래스, API와 동일한 필드 이름.
설치
bash
npm install @emini-ai/sdk사용법
typescript
import { EminiAI } from "@emini-ai/sdk";
const client = new EminiAI({ apiKey: process.env.EMINI_API_KEY! });
const result = await client.chat.completions.create({
messages: [{ role: "user", content: "Bonjour" }],
model: "claude-opus-5",
});
console.log(result.content);스트리밍
typescript
for await (const chunk of client.chat.completions.stream({
messages: [{ role: "user", content: "Compte jusqu'a 10" }],
})) {
process.stdout.write(chunk.delta);
}비동기 작업 (비디오)
typescript
const generation = await client.video.generate({ prompt: "un chat qui code" });
const job = await generation.wait(); // sonde /v1/jobs/{id} jusqu'a completion
console.log(job.result_url);타입이 지정된 오류
코드를 수동으로 파싱하지 않도록 HTTP 상태 범위별로 하위 클래스를 제공합니다:
typescript
import { InsufficientCreditsError } from "@emini-ai/sdk";
try {
await client.chat.completions.create({ messages: [/* ... */] });
} catch (err) {
if (err instanceof InsufficientCreditsError) {
// credits insuffisants sur le compte (402)
}
}각 클래스와 관련된 HTTP 코드의 전체 목록은 오류 레퍼런스를 참고하세요.
지원 리소스
chat, images, vision, embeddings, translation, audio, video, jobs, uploads, agents — Gateway의 각 카테고리별로 하나의 클래스.
소스 코드
모노레포의 sdks/js.