English | 中文 | 日本語

# AIゲートウェイ #### 1つの高速でフレンドリーなAPIで200以上のLLMに確実にルーティング Gateway Demo
[![License](https://img.shields.io/github/license/Ileriayo/markdown-badges)](./LICENSE) [![Discord](https://img.shields.io/discord/1143393887742861333)](https://portkey.ai/community) [![Twitter](https://img.shields.io/twitter/url/https/twitter/follow/portkeyai?style=social&label=Follow%20%40PortkeyAI)](https://twitter.com/portkeyai) [![npm version](https://badge.fury.io/js/%40portkey-ai%2Fgateway.svg)](https://www.npmjs.com/package/@portkey-ai/gateway) [![Better Stack Badge](https://uptime.betterstack.com/status-badges/v1/monitor/q94g.svg)](https://status.portkey.ai/?utm_source=status_badge)
[AIゲートウェイ](https://portkey.ai/features/ai-gateway)は、250以上の言語、ビジョン、オーディオ、画像モデルへのリクエストを統一されたAPIで簡素化します。キャッシング、フォールバック、リトライ、タイムアウト、ロードバランシングをサポートし、最小の遅延でエッジデプロイが可能なプロダクション対応のゲートウェイです。 ✅  **超高速**(9.9倍速)で**小さなフットプリント**(ビルド後約100kb)
✅  複数のモデル、プロバイダー、キー間で**ロードバランシング**
✅  **フォールバック**でアプリの信頼性を確保
✅  デフォルトで**自動リトライ**(指数関数的フォールバック)
✅  **リクエストタイムアウト**の設定が可能
✅  **マルチモーダル**でビジョン、TTS、STT、画像生成モデルをサポート
✅  必要に応じてミドルウェアを**プラグイン**
✅  **480Bトークン**以上の実績
✅  **エンタープライズ対応**でセキュリティ、スケール、カスタムデプロイメントをサポート

> [!TIP] > ⭐️ **このリポジトリにスターを付ける**ことで、新しいプロバイダー統合や機能のGitHubリリース通知を受け取ることができます。 ![star-2](https://github.com/user-attachments/assets/53597dce-6333-4ecc-a154-eb05532954e4)
スター履歴

## セットアップとインストール AIゲートウェイを使用するには、**ホストされたAPI**を使用するか、**オープンソース**または**エンタープライズバージョン**を自分の環境にセルフホストします。
### 👉 portkey.aiでホストされたゲートウェイ(最速) ホストされたAPIは、ジェネレーティブAIアプリケーションのためのAIゲートウェイをセットアップする最速の方法です。私たちは**毎日数十億のトークン**を処理しており、Postman、Haptik、Turing、MultiOn、SiteGPTなどの企業でプロダクションで使用されています。 Get API Key

### 👉 オープンソースバージョンのセルフホスト([MITライセンス](https://github.com/Portkey-AI/gateway?tab=MIT-1-ov-file#readme)) ローカルでAIゲートウェイを実行するには、ターミナルで以下のコマンドを実行します。(npxがインストールされている必要があります)または、[Cloudflare](https://github.com/Portkey-AI/gateway/blob/main/docs/installation-deployments.md#cloudflare-workers)、[Docker](https://github.com/Portkey-AI/gateway/blob/main/docs/installation-deployments.md#docker)、[Node.js](https://github.com/Portkey-AI/gateway/blob/main/docs/installation-deployments.md#nodejs-server)などのデプロイメントガイドを参照してください。 ```bash npx @portkey-ai/gateway ``` あなたのAIゲートウェイはhttp://localhost:8787で実行されています 🚀
### 👉 エンタープライズバージョンのセルフホスト AIゲートウェイのエンタープライズバージョンは、**組織管理**、**ガバナンス**、**セキュリティ**などのエンタープライズ対応機能を提供します。オープンソース、ホスト、エンタープライズバージョンの比較は[こちら](https://docs.portkey.ai/docs/product/product-feature-comparison)をご覧ください。 エンタープライズデプロイメントアーキテクチャ、サポートされているプラットフォームについては、[**エンタープライズプライベートクラウドデプロイメント**](https://docs.portkey.ai/docs/product/enterprise-offering/private-cloud-deployments)をご覧ください。 Book an enterprise AI gateway demo

## AIゲートウェイを通じたリクエストの作成 ### OpenAI API & SDKと互換性あり AIゲートウェイはOpenAI API & SDKと互換性があり、200以上のLLMに信頼性のある呼び出しを拡張します。ゲートウェイを通じてOpenAIを使用するには、**クライアントを更新**してゲートウェイのURLとヘッダーを含め、通常通りリクエストを行います。AIゲートウェイは、OpenAI形式で書かれたリクエストを指定されたプロバイダーが期待するシグネチャに変換できます。[例を表示](https://docs.portkey.ai/docs/guides/getting-started/getting-started-with-ai-gateway)

### Python SDKの使用    [Portkey Python SDK](https://github.com/Portkey-AI/portkey-python-sdk)は、OpenAI Python SDKのラッパーであり、他のすべてのプロバイダーに対する追加パラメータのサポートを提供します。**Pythonで構築している場合、これはゲートウェイに接続するための推奨ライブラリです**。 ```bash pip install -qU portkey-ai ```
### Node.JS SDKの使用 [Portkey JS/TS SDK](https://www.npmjs.com/package/portkey-ai)は、OpenAI JS SDKのラッパーであり、他のすべてのプロバイダーに対する追加パラメータのサポートを提供します。**JSまたはTSで構築している場合、これはゲートウェイに接続するための推奨ライブラリです**。 ```bash npm install --save portkey-ai ```
### REST APIの使用 AIゲートウェイは、すべての他のプロバイダーとモデルに対する追加パラメータのサポートを備えたOpenAI互換エンドポイントをサポートします。[APIリファレンスを表示](https://docs.portkey.ai/docs/api-reference/introduction)。

### その他の統合 | 言語 | サポートされているSDK | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | JS / TS | [LangchainJS](https://www.npmjs.com/package/langchain)
[LlamaIndex.TS](https://www.npmjs.com/package/llamaindex) | | Python |
[Langchain](https://portkey.ai/docs/welcome/integration-guides/langchain-python)
[LlamaIndex](https://portkey.ai/docs/welcome/integration-guides/llama-index-python) | | Go | [go-openai](https://github.com/sashabaranov/go-openai) | | Java | [openai-java](https://github.com/TheoKanning/openai-java) | | Rust | [async-openai](https://docs.rs/async-openai/latest/async_openai/) | | Ruby | [ruby-openai](https://github.com/alexrudall/ruby-openai) |
## ゲートウェイクックブック ### トレンドのクックブック - [Nvidia NIM](/cookbook/providers/nvidia.ipynb)のモデルをAIゲートウェイで使用する - [CrewAIエージェント](/cookbook/monitoring-agents/CrewAI_with_Telemetry.ipynb)をPortkeyで監視する - AIゲートウェイで[トップ10のLMSYSモデルを比較する](./use-cases/LMSYS%20Series/comparing-top10-LMSYS-models-with-Portkey.ipynb) ### 最新のクックブック * [Nemotronを使用して合成データセットを作成する](/cookbook/use-cases/Nemotron_GPT_Finetuning_Portkey.ipynb) * [PortkeyゲートウェイをVercelのAI SDKと使用する](/cookbook/integrations/vercel-ai.md) * [PortkeyでLlamaエージェントを監視する](/cookbook/monitoring-agents/Llama_Agents_with_Telemetry.ipynb) ### [その他の例](https://github.com/Portkey-AI/gateway/tree/main/cookbook) ## サポートされているプロバイダー [25以上のプロバイダー](https://portkey.ai/docs/welcome/integration-guides)と[6以上のフレームワーク](https://portkey.ai/docs/welcome/integration-guides)とのゲートウェイ統合を探索してください。 | | プロバイダー | サポート | ストリーム | | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------- | ------ | | | [OpenAI](https://portkey.ai/docs/welcome/integration-guides/openai) | ✅ | ✅ | | | [Azure OpenAI](https://portkey.ai/docs/welcome/integration-guides/azure-openai) | ✅ | ✅ | | | [Anyscale](https://portkey.ai/docs/welcome/integration-guides/anyscale-llama2-mistral-zephyr) | ✅ | ✅ | | | [Google Gemini & Palm](https://portkey.ai/docs/welcome/integration-guides/gemini) | ✅ | ✅ | | | [Anthropic](https://portkey.ai/docs/welcome/integration-guides/anthropic) | ✅ | ✅ | | | [Cohere](https://portkey.ai/docs/welcome/integration-guides/cohere) | ✅ | ✅ | | | [Together AI](https://portkey.ai/docs/welcome/integration-guides/together-ai) | ✅ | ✅ | | | [Perplexity](https://portkey.ai/docs/welcome/integration-guides/perplexity-ai) | ✅ | ✅ | | | [Mistral](https://portkey.ai/docs/welcome/integration-guides/mistral-ai) | ✅ | ✅ | | | [Nomic](https://portkey.ai/docs/welcome/integration-guides/nomic) | ✅ | ✅ | | | [AI21](https://portkey.ai/docs/welcome/integration-guides) | ✅ | ✅ | | | [Stability AI](https://portkey.ai/docs/welcome/integration-guides/stability-ai) | ✅ | ✅ | | | [DeepInfra](https://portkey.ai/docs/welcome/integration-guides) | ✅ | ✅ | | | [Ollama](https://portkey.ai/docs/welcome/integration-guides/ollama) | ✅ | ✅ | | | Novita AI | ✅ | ✅ | `/chat/completions`, `/completions` | > [サポートされている200以上のモデルの完全なリストを表示](https://portkey.ai/docs/welcome/what-is-portkey#ai-providers-supported)

## エージェント ゲートウェイは、人気のあるエージェントフレームワークとシームレスに統合されます。[ドキュメントを読む](https://docs.portkey.ai/docs/welcome/agents)。 | フレームワーク | 200以上のLLMを呼び出す | 高度なルーティング | キャッシング | ロギングとトレース* | オブザーバビリティ* | プロンプト管理* | |------------------------------|--------|-------------|---------|------|---------------|-------------------| | [Autogen](https://docs.portkey.ai/docs/welcome/agents/autogen) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [CrewAI](https://docs.portkey.ai/docs/welcome/agents/crewai) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [LangChain](https://docs.portkey.ai/docs/welcome/agents/langchain-agents) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [Phidata](https://docs.portkey.ai/docs/welcome/agents/phidata) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [Llama Index](https://docs.portkey.ai/docs/welcome/agents/llama-agents) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [Control Flow](https://docs.portkey.ai/docs/welcome/agents/control-flow) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [独自のエージェントを構築する](https://docs.portkey.ai/docs/welcome/agents/bring-your-own-agents) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
*ホストされたアプリでのみ利用可能です。詳細なドキュメントは[こちら](https://docs.portkey.ai/docs/welcome/agents)をご覧ください。 ## 機能
フォールバック
失敗したリクエストに対して別のプロバイダーやモデルにフォールバックします。トリガーするエラーを指定できます。アプリケーションの信頼性を向上させます。

自動リトライ
失敗したリクエストを最大5回自動的にリトライします。指数関数的バックオフ戦略により、リトライ試行の間隔を空けてネットワークの過負荷を防ぎます。

ロードバランシング
複数のAPIキーやAIプロバイダー間でLLMリクエストを重み付けして分散させ、高可用性と最適なパフォーマンスを確保します。

リクエストタイムアウト

応答しないLLMリクエストを自動的に終了させるために、詳細なリクエストタイムアウトを設定します。

マルチモーダルLLMゲートウェイ
ビジョン、オーディオ(テキストから音声、音声からテキスト)、画像生成モデルを複数のプロバイダーから呼び出すことができます — すべてOpenAIのシグネチャを使用して

ガードレール

指定されたチェックに従ってLLMの入力と出力をリアルタイムで検証します。独自のチェックを作成するか、20以上の事前構築されたガードレールから選択できます。

**これらの機能は、`x-portkey-config`ヘッダーまたはSDKの`config`パラメータに追加されたゲートウェイ設定を通じて構成されます。** 以下は、上記の機能を示すサンプル設定JSONです。すべての機能はオプションです。 ```json { "retry": { "attempts": 5 }, "request_timeout": 10000, "strategy": { "mode": "fallback" }, // または 'loadbalance' など "targets": [{ "provider": "openai", "api_key": "sk-***" },{ "strategy": {"mode": "loadbalance"}, // オプションのネスト "targets": {...} }] } ``` 次に、APIリクエストに設定を使用します。 ### ゲートウェイ設定の使用 リクエストで設定オブジェクトを使用する方法については、[こちらのガイド](https://portkey.ai/docs/api-reference/config-object)をご覧ください。
## ゲートウェイエンタープライズバージョン AIアプリを信頼性将来の互換性を高め、完全なデータセキュリティプライバシーを確保します。 ✅  セキュアなキー管理 - ロールベースのアクセス制御とトラッキングのため
✅  シンプルでセマンティックなキャッシング - 繰り返しのクエリを高速に提供し、コストを削減
✅  アクセス制御とインバウンドルール - 接続できるIPと地域を制御
✅  PII削除 - リクエストから自動的に機密データを削除し、意図しない露出を防止
✅  SOC2、ISO、HIPAA、GDPRコンプライアンス - ベストセキュリティプラクティスのため
✅  プロフェッショナルサポート - 機能の優先順位付けとともに
[エンタープライズデプロイメントについての相談を予約する](https://portkey.sh/demo-22)
## 貢献 最も簡単な貢献方法は、`good first issue`タグの付いた問題を選ぶことです 💪。貢献ガイドラインは[こちら](/.github/CONTRIBUTING.md)をご覧ください。 バグ報告?[こちらで提出](https://github.com/Portkey-AI/gateway/issues) | 機能リクエスト?[こちらで提出](https://github.com/Portkey-AI/gateway/issues)
## コミュニティ 世界中の成長するコミュニティに参加して、AIに関するヘルプ、アイデア、ディスカッションを行いましょう。 - 公式[ブログ](https://portkey.ai/blog)を閲覧する - [Discord](https://portkey.ai/community)でリアルタイムチャット - [Twitter](https://twitter.com/PortkeyAI)でフォロー - [LinkedIn](https://www.linkedin.com/company/portkey-ai/)で接続 - [日本語のドキュメント](./.github/README.jp.md)を読む ![Rubeus Social Share (4)](https://github.com/Portkey-AI/gateway/assets/971978/89d6f0af-a95d-4402-b451-14764c40d03f)