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

# Integrations モジュール

> `base44.integrations` を介してサードパーティサービスにアクセスします。

<Warning>
  このページは AI コーディングエージェントスキルの一部で、人間ではなくエージェント向けに書かれています。人間向けの Base44 ドキュメントは [デベロッパードキュメント](/developers) を参照してください。
</Warning>

# Integrations モジュール

`base44.integrations` を介してサードパーティサービスにアクセスします。

## インテグレーションの種類

1. **Core/Built-in**: AI、メール、ファイルアップロード (デフォルトで利用可能)
2. **カタログインテグレーション**: Base44 カタログからの事前構築済みコネクタ
3. **カスタムインテグレーション**: 独自の OpenAPI ベースのインテグレーション

## インテグレーションへのアクセス

```javascript theme={null}
// Core integrations
base44.integrations.Core.FunctionName(params)

// Custom integrations
base44.integrations.custom.call(slug, operationId, params)
```

## Core インテグレーション

### InvokeLLM (AI テキスト生成)

AI モデルを使用してテキストまたは構造化された JSON データを生成します。

```javascript theme={null}
// Basic prompt - returns string
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "Summarize this text: ..."
});

// With internet context (uses Google Search, Maps, News)
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "What's the current weather in NYC?",
  add_context_from_internet: true
});

// Structured JSON response - returns object
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "Analyze the sentiment of: 'Great product but slow shipping'",
  response_json_schema: {
    type: "object",
    properties: {
      sentiment: { type: "string", enum: ["positive", "negative", "mixed"] },
      score: { type: "number", description: "Score from 1-10" },
      key_points: { type: "array", items: { type: "string" } }
    }
  }
});
// Returns: { sentiment: "mixed", score: 7, key_points: ["great product", "slow shipping"] }

// With file attachments (uploaded via UploadFile)
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "Describe what's in this image",
  file_urls: ["https://...uploaded_image.png"]
});
```

**パラメーター:**

* `prompt` (string, 必須): モデルに送信するプロンプトテキスト
* `add_context_from_internet` (boolean, オプション): true の場合、リアルタイムコンテキストに Google Search/Maps/News を使用
* `response_json_schema` (object, オプション): 構造化出力用の JSON スキーマ
* `file_urls` (string\[], オプション): コンテキスト用のアップロード済みファイルの URL

### GenerateImage

テキストプロンプトから AI 生成の画像を作成します。

```javascript theme={null}
const { url } = await base44.integrations.Core.GenerateImage({
  prompt: "A serene mountain landscape with a lake"
});
console.log(url); // https://...generated_image.png
```

### SendEmail

登録済みユーザーにメールを送信します。すべてのアプリでこのインテグレーションを利用できます (プランのアップグレード不要)。

```javascript theme={null}
await base44.integrations.Core.SendEmail({
  to: "user@example.com",
  subject: "Welcome!",
  body: "<h1>Hello</h1><p>Welcome to our app.</p>",
  from_name: "My App"  // optional, defaults to app name
});
```

**パラメーター:**

* `to` (string, 必須): 受信者のメールアドレス
* `subject` (string, 必須): メール件名
* `body` (string, 必須): プレーンテキストまたは HTML のメール本文
* `from_name` (string, オプション): 受信者に表示される送信者名

**制限事項:**

* メール 1 件につき 1 クレジット (カスタムドメインで 2 クレジット)

### UploadFile (公開)

ファイルを公開ストレージにアップロードします。

```javascript theme={null}
const fileInput = document.querySelector('input[type="file"]');
const { file_url } = await base44.integrations.Core.UploadFile({
  file: fileInput.files[0]
});
console.log(file_url); // https://...uploaded_file.pdf
```

### UploadPrivateFile

アクセスに署名付き URL が必要なプライベートストレージにファイルをアップロードします。

```javascript theme={null}
const { file_uri } = await base44.integrations.Core.UploadPrivateFile({
  file: fileInput.files[0]
});
console.log(file_uri); // "private/user123/document.pdf"

// Create a signed URL to access the file
const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
  file_uri,
  expires_in: 3600  // URL expires in 1 hour (default: 300 seconds)
});
console.log(signed_url); // Temporary URL to access the private file
```

### CreateFileSignedUrl

プライベートファイル用の一時的なアクセスリンクを生成します。

```javascript theme={null}
const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
  file_uri: "private/user123/document.pdf",
  expires_in: 7200  // 2 hours
});
```

**パラメーター:**

* `file_uri` (string, 必須): UploadPrivateFile からの URI
* `expires_in` (number, オプション): 秒単位の有効期限 (デフォルト: 300)

### ExtractDataFromUploadedFile

AI を使用してアップロード済みファイルから構造化データを抽出します。

```javascript theme={null}
// First upload the file
const { file_url } = await base44.integrations.Core.UploadFile({ file });

// Then extract structured data
const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
  file_url,
  json_schema: {
    type: "object",
    properties: {
      invoice_number: { type: "string" },
      total_amount: { type: "number" },
      date: { type: "string" },
      vendor_name: { type: "string" }
    }
  }
});
console.log(result); // { invoice_number: "INV-12345", total_amount: 1250.00, ... }
```

## カスタムインテグレーション

カスタムインテグレーションを使うと、ワークスペース管理者は OpenAPI 仕様をインポートすることで任意の外部 API に接続できます。呼び出すには `base44.integrations.custom.call()` を使用します。

### 構文

```javascript theme={null}
const response = await base44.integrations.custom.call(
  slug,        // Integration identifier (set by admin)
  operationId, // Endpoint in "method:path" format (e.g. "get:/contacts", "post:/repos/{owner}/{repo}/issues")
  params       // Optional: payload, pathParams, queryParams
);
```

### 例

```javascript theme={null}
// GET request with query params
const response = await base44.integrations.custom.call(
  "my-crm",
  "get:/contacts",
  { queryParams: { limit: 10, status: "active" } }
);

// POST request with body
const response = await base44.integrations.custom.call(
  "my-crm",
  "post:/contacts",
  { payload: { name: "John Doe", email: "john@example.com" } }
);

// Request with path parameters
const response = await base44.integrations.custom.call(
  "github",
  "post:/repos/{owner}/{repo}/issues",
  {
    pathParams: { owner: "myorg", repo: "myrepo" },
    payload: { title: "Bug report", body: "Something is broken" }
  }
);
```

### レスポンス構造

```javascript theme={null}
{
  success: true,      // Whether external API returned 2xx
  status_code: 200,   // HTTP status code
  data: { ... }       // Response from external API
}
```

## 要件

* **Core インテグレーション**: すべてのプランで利用可能
* **カタログ/カスタムインテグレーション**: Builder プラン以上が必要

## 型定義

### Core インテグレーションパラメーター

```typescript theme={null}
/** Parameters for the InvokeLLM function. */
interface InvokeLLMParams {
  /** The prompt text to send to the model. */
  prompt: string;
  /** If true, uses Google Search/Maps/News for real-time context. */
  add_context_from_internet?: boolean;
  /** JSON schema for structured output. If provided, returns object instead of string. */
  response_json_schema?: object;
  /** File URLs (from UploadFile) to provide as context. */
  file_urls?: string[];
}

/** Parameters for the GenerateImage function. */
interface GenerateImageParams {
  /** Description of the image to generate. */
  prompt: string;
}

/** Result from GenerateImage. */
interface GenerateImageResult {
  /** URL of the generated image. */
  url: string;
}

/** Parameters for the UploadFile function. */
interface UploadFileParams {
  /** The file object to upload. */
  file: File;
}

/** Result from UploadFile. */
interface UploadFileResult {
  /** URL of the uploaded file. */
  file_url: string;
}

/** Parameters for the SendEmail function. */
interface SendEmailParams {
  /** Recipient email address. */
  to: string;
  /** Email subject line. */
  subject: string;
  /** Plain text or HTML email body. */
  body: string;
  /** Sender name (defaults to app name). */
  from_name?: string;
}

/** Parameters for ExtractDataFromUploadedFile. */
interface ExtractDataFromUploadedFileParams {
  /** URL of the uploaded file. */
  file_url: string;
  /** JSON schema defining fields to extract. */
  json_schema: object;
}

/** Parameters for UploadPrivateFile. */
interface UploadPrivateFileParams {
  /** The file object to upload. */
  file: File;
}

/** Result from UploadPrivateFile. */
interface UploadPrivateFileResult {
  /** URI of the private file (used for signed URLs). */
  file_uri: string;
}

/** Parameters for CreateFileSignedUrl. */
interface CreateFileSignedUrlParams {
  /** URI from UploadPrivateFile. */
  file_uri: string;
  /** Expiration time in seconds (default: 300). */
  expires_in?: number;
}

/** Result from CreateFileSignedUrl. */
interface CreateFileSignedUrlResult {
  /** Temporary signed URL to access the file. */
  signed_url: string;
}
```

### CoreIntegrations

```typescript theme={null}
/** Core package containing built-in Base44 integration functions. */
interface CoreIntegrations {
  InvokeLLM(params: InvokeLLMParams): Promise<string | object>;
  GenerateImage(params: GenerateImageParams): Promise<GenerateImageResult>;
  UploadFile(params: UploadFileParams): Promise<UploadFileResult>;
  SendEmail(params: SendEmailParams): Promise<any>;
  ExtractDataFromUploadedFile(params: ExtractDataFromUploadedFileParams): Promise<object>;
  UploadPrivateFile(params: UploadPrivateFileParams): Promise<UploadPrivateFileResult>;
  CreateFileSignedUrl(params: CreateFileSignedUrlParams): Promise<CreateFileSignedUrlResult>;
}
```

### カスタムインテグレーション

```typescript theme={null}
/** Parameters for calling a custom integration method. */
interface CustomIntegrationCallParams {
  /** Request body payload. */
  payload?: Record<string, any>;
  /** Path parameters to substitute in the URL. For example, { owner: "user", repo: "repo" }. */
  pathParams?: Record<string, string>;
  /** Query string parameters. */
  queryParams?: Record<string, any>;
}

/** Response from a custom integration call. */
interface CustomIntegrationCallResponse {
  /** Whether the external API returned a 2xx status code. */
  success: boolean;
  /** The HTTP status code from the external API. */
  status_code: number;
  /** The response data from the external API. */
  data: any;
}

/** Module for calling custom pre-configured API integrations. */
interface CustomIntegrationsModule {
  /**
   * Call a custom integration method.
   * @param slug - The integration's unique identifier (set by workspace admin).
   * @param operationId - The endpoint in "method:path" format (e.g. "get:/contacts", "post:/users/{id}").
   * @param params - Optional payload, pathParams, queryParams.
   */
  call(slug: string, operationId: string, params?: CustomIntegrationCallParams): Promise<CustomIntegrationCallResponse>;
}
```

### IntegrationsModule

```typescript theme={null}
/** Integrations module for calling integration methods. */
type IntegrationsModule = {
  /** Core package with built-in integrations. */
  Core: CoreIntegrations;
  /** Custom integrations module. */
  custom: CustomIntegrationsModule;
  /** Additional integration packages (dynamic). */
  [packageName: string]: any;
};
```

<Note>このページは AI を使用して翻訳されました。最も正確で最新の情報については、[英語版](/) を参照してください。 </Note>
