API 참조

상세한 메서드 설명, 매개변수 및 실용적인 예제가 포함된 완전한 Gemini CLI API 문서.

API 섹션

다양한 API 카테고리 탐색

핵심 API

Gemini 모델과 상호작용하고 대화를 관리하기 위한 주요 API

플러그인 API

사용자 정의 플러그인 및 확장 개발을 위한 API

구성 API

CLI 구성 및 설정 관리를 위한 API

도구 API

내장 도구 관리 및 실행을 위한 API

핵심 API

Gemini 모델과 상호작용하고 대화를 관리하기 위한 주요 API

chat()

Gemini와 대화형 채팅 세션 시작

시그니처:

chat(options?: ChatOptions): Promise<ChatSession>

예제:

import { GeminiCLI } from '@google/generative-ai-cli';

const cli = new GeminiCLI();
const session = await cli.chat({
  model: 'gemini-pro',
  temperature: 0.7
});

ask()

프롬프트를 보내고 응답 받기

시그니처:

ask(prompt: string, options?: AskOptions): Promise<string>

예제:

const response = await cli.ask("머신러닝이란 무엇인가요?", {
  maxTokens: 1000,
  temperature: 0.5
});

analyze()

AI 지원으로 파일이나 코드 분석

시그니처:

analyze(files: string[], options?: AnalyzeOptions): Promise<AnalysisResult>

예제:

const analysis = await cli.analyze(['src/main.js'], {
  type: 'code-review',
  includeMetrics: true
});

플러그인 API

사용자 정의 플러그인 및 확장 개발을 위한 API

registerPlugin()

CLI에 새 플러그인 등록

시그니처:

registerPlugin(plugin: Plugin): void

예제:

const myPlugin = {
  name: 'my-custom-plugin',
  version: '1.0.0',
  commands: {
    'custom-command': async (args) => {
      // 플러그인 로직 여기
      return '플러그인이 성공적으로 실행됨';
    }
  }
};

cli.registerPlugin(myPlugin);

createTool()

AI용 사용자 정의 도구 생성

시그니처:

createTool(definition: ToolDefinition): Tool

예제:

const weatherTool = cli.createTool({
  name: 'get_weather',
  description: '지정된 위치의 현재 날씨 가져오기',
  parameters: {
    location: { type: 'string', required: true }
  },
  execute: async ({ location }) => {
    // 날씨 데이터 가져오기
    return `${location}의 날씨: 맑음, 25°C`;
  }
});

시그니처:

예제:

시그니처:

예제:

시그니처:

예제:

시그니처:

예제:

시그니처:

예제:

string

number

number

string

string

string

object

function