jpskill.com
💼 ビジネス コミュニティ

ai-gateway

Manages AI gateway for routing, securing, and monitoring AI service requests in ML operations.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ai-gateway.zip https://jpskill.com/download/22011.zip && unzip -o ai-gateway.zip && rm ai-gateway.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22011.zip -OutFile "$d\ai-gateway.zip"; Expand-Archive "$d\ai-gateway.zip" -DestinationPath $d -Force; ri "$d\ai-gateway.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して ai-gateway.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → ai-gateway フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

ai-gateway

目的

このスキルは、MLオペレーションにおけるAIサービスリクエストのルーティング、セキュリティ、監視のためのAIゲートウェイを管理し、aimlopsクラスター内での効率的なトラフィック処理、APIセキュリティ、パフォーマンス追跡を保証します。

使用する場面

複数のAIモデルを持つ本番環境など、AIリクエストの一元的なルーティングが必要なMLパイプラインを構築する際に、セキュリティポリシーの適用、トラフィックの監視、APIエンドポイントのスケーリングのためにこのスキルを使用します。AI推論のためのマイクロサービスを扱うシナリオや、aimlopsワークフローのためにKubernetesのようなツールと統合する場合に適用してください。

主な機能

  • ルーティング: パスベースまたはヘッダーベースのマッチングを使用して、ルールに基づいてAIサービスにリクエストを動的にルーティングします。
  • セキュリティ: JWTまたはAPIキーを介して、認証、レート制限、暗号化を強制します。
  • 監視: 統合されたロギングとPrometheusエクスポーターを通じて、リクエストのレイテンシやエラー率などのメトリクスを追跡します。
  • 設定: ルートを定義するためのYAMLベースの設定をサポートし、例えば、送信元と送信先のエンドポイントを指定します。
  • スケーラビリティ: 自動フェイルオーバーにより、複数のAIバックエンド間でロードバランシングを処理します。

使用パターン

このスキルを使用するには、まずCLIまたはAPIを介してAIゲートウェイを設定し、次にルートとセキュリティルールを定義します。常に$AI_GATEWAY_API_KEY環境変数を使用してリクエストを認証してください。CLIを使用する場合は、ai-gateway-cli init --config path/to/config.yamlで初期化し、ai-gateway-cli applyで変更を適用します。コードでは、SDKをインポートし、プログラムによる設定のためにcreateRoute()のようなメソッドを呼び出します。メトリクスエンドポイントを定期的にクエリすることで使用状況を監視します。

一般的なコマンド/API

  • CLIコマンド:

    • ゲートウェイの初期化: ai-gateway-cli init --cluster aimlops --key $AI_GATEWAY_API_KEY
    • ルートの追加: ai-gateway-cli add-route --path /predict --target http://ai-service:8080 --method POST
    • エンドポイントの保護: ai-gateway-cli secure --endpoint /predict --auth jwt --rate-limit 100/min
    • メトリクスの表示: ai-gateway-cli metrics --format json
  • APIエンドポイント:

    • ルートの作成: POST /api/v1/routes (ボディ: { "path": "/predict", "target": "http://ai-service:8080", "method": "POST" })
    • セキュリティの更新: PUT /api/v1/security/{endpoint} (ボディ: { "authType": "jwt", "rateLimit": 100 })
    • メトリクスの取得: GET /api/v1/metrics?type=latency
  • コードスニペット:

    import requests
    headers = {'Authorization': f'Bearer {os.environ.get("AI_GATEWAY_API_KEY")}'}
    response = requests.post('http://gateway:8080/api/v1/routes', json={"path": "/predict", "target": "http://ai-service:8080"}, headers=headers)
    export AI_GATEWAY_API_KEY=your_api_key_here
    ai-gateway-cli add-route --path /chat --target http://llm-service:5000
  • 設定形式: 設定にはYAMLを使用します。例:

    routes:
      - path: /predict
        target: http://ai-service:8080
        methods: [POST]
    security:
      - endpoint: /predict
        auth: jwt
        rateLimit: 100

統合に関する注意点

ゲートウェイをクラスター内のサイドカーまたはスタンドアロンサービスとしてデプロイすることで、aimlopsと統合します。Kubernetesの場合、ポッドにアノテーションを追加します。例: kubectl annotate pod ai-pod aimlops/gateway=true。SDKを使用して他のAIツールと連携します。AI_Gateway(api_key=os.environ['AI_GATEWAY_API_KEY']).connect(cluster='aimlops')でインポートして初期化します。「ai」や「mlops」のようなタグを一致させることで互換性を確保します。外部サービスの場合、設定でゲートウェイのコールバックURLを設定することでウェブフックを設定します。例: YAMLにcallback: http://external-service/webhookを追加します。

エラー処理

APIレスポンスのHTTPステータスコードを確認することでエラーを処理します。例えば、401は認証失敗を示しますので、headers['Authorization'] = f'Bearer {new_key}'で再試行してください。CLIの場合、「Error: Invalid route path」のような出力エラーを解析し、入力を修正します。一般的な問題にはAPIキーの欠落があります。常にif not os.environ.get('AI_GATEWAY_API_KEY'): raise ValueError('API key required')で確認してください。ゲートウェイの組み込みロガーを使用してエラーをログに記録します。ai-gateway-cli config --log-level debugで有効にし、レート制限超過などのパターンを監視し、コードで指数バックオフによる再試行を実装します。

具体的な使用例

  1. AIリクエストのルーティング: MLモデルへの予測リクエストをルーティングするには、まずAPIキーをエクスポートし、次にCLIを使用します: export AI_GATEWAY_API_KEY=abc123; ai-gateway-cli add-route --path /ml-predict --target http://model-service:8000。curlリクエストで確認します: curl -H "Authorization: Bearer abc123" http://gateway:8080/ml-predict -d '{"input": "data"}'

  2. APIの保護と監視: エンドポイントを保護し、トラフィックを監視するには、以下を実行します: ai-gateway-cli secure --endpoint /chat --auth api-key --rate-limit 50/min。次に、メトリクスをクエリします: ai-gateway-cli metrics --endpoint /chat。コードでは、次のように処理します: ```python import requests; headers = {'Authorization': f'Bearer {os.environ["AI_GATEWAY_API_KEY"]}'}; requests.get('http://gateway:8080/api/v1/metrics', headers=headers)

グラフの関係

  • 関連: aimlops (クラスター), ai (タグ), mlops (タグ)
  • 依存: セキュリティのための認証サービス
  • 使用元: ルーティングと監視のためのAIサービス
  • 統合: デプロイのためのKubernetes、メトリクス収集のためのPrometheus
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

ai-gateway

Purpose

This skill manages an AI gateway for routing, securing, and monitoring AI service requests in ML operations, ensuring efficient traffic handling, API security, and performance tracking within the aimlops cluster.

When to Use

Use this skill when building ML pipelines that require centralized routing of AI requests, such as in production environments with multiple AI models, to enforce security policies, monitor traffic, or scale API endpoints. Apply it in scenarios involving microservices for AI inference or when integrating with tools like Kubernetes for aimlops workflows.

Key Capabilities

  • Routing: Dynamically route requests to AI services based on rules, using path-based or header-based matching.
  • Security: Enforce authentication, rate limiting, and encryption via JWT or API keys.
  • Monitoring: Track metrics like request latency and error rates through integrated logging and Prometheus exporters.
  • Configuration: Support YAML-based configs for defining routes, e.g., specifying source and destination endpoints.
  • Scalability: Handle load balancing across multiple AI backends with automatic failover.

Usage Patterns

To use this skill, first set up the AI gateway via CLI or API, then define routes and security rules. Always authenticate requests using the $AI_GATEWAY_API_KEY environment variable. For CLI usage, initialize with ai-gateway-cli init --config path/to/config.yaml, then apply changes with ai-gateway-cli apply. In code, import the SDK and call methods like createRoute() for programmatic setup. Monitor usage by querying metrics endpoints periodically.

Common Commands/API

  • CLI Commands:

    • Initialize gateway: ai-gateway-cli init --cluster aimlops --key $AI_GATEWAY_API_KEY
    • Add a route: ai-gateway-cli add-route --path /predict --target http://ai-service:8080 --method POST
    • Secure an endpoint: ai-gateway-cli secure --endpoint /predict --auth jwt --rate-limit 100/min
    • View metrics: ai-gateway-cli metrics --format json
  • API Endpoints:

    • Create route: POST /api/v1/routes with body { "path": "/predict", "target": "http://ai-service:8080", "method": "POST" }
    • Update security: PUT /api/v1/security/{endpoint} with body { "authType": "jwt", "rateLimit": 100 }
    • Get metrics: GET /api/v1/metrics?type=latency
  • Code Snippets:

    import requests
    headers = {'Authorization': f'Bearer {os.environ.get("AI_GATEWAY_API_KEY")}'}
    response = requests.post('http://gateway:8080/api/v1/routes', json={"path": "/predict", "target": "http://ai-service:8080"}, headers=headers)
    export AI_GATEWAY_API_KEY=your_api_key_here
    ai-gateway-cli add-route --path /chat --target http://llm-service:5000
  • Config Formats: Use YAML for configurations, e.g.:

    routes:
      - path: /predict
        target: http://ai-service:8080
        methods: [POST]
    security:
      - endpoint: /predict
        auth: jwt
        rateLimit: 100

Integration Notes

Integrate with aimlops by deploying the gateway as a sidecar or standalone service in your cluster. For Kubernetes, add annotations to pods, e.g., kubectl annotate pod ai-pod aimlops/gateway=true. Use the SDK to link with other AI tools: import and initialize with AI_Gateway(api_key=os.environ['AI_GATEWAY_API_KEY']).connect(cluster='aimlops'). Ensure compatibility by matching tags like "ai" and "mlops". For external services, set up webhooks by configuring the gateway's callback URL in your config, e.g., add callback: http://external-service/webhook in YAML.

Error Handling

Handle errors by checking HTTP status codes from API responses; for example, 401 indicates authentication failure, so retry with headers['Authorization'] = f'Bearer {new_key}'. For CLI, parse output errors like "Error: Invalid route path" and correct inputs. Common issues include missing API keys—always verify if not os.environ.get('AI_GATEWAY_API_KEY'): raise ValueError('API key required'). Log errors using the gateway's built-in logger: enable with ai-gateway-cli config --log-level debug, then monitor for patterns like rate limit exceedances and implement retries with exponential backoff in code.

Concrete Usage Examples

  1. Route AI Requests: To route prediction requests to an ML model, first export your API key, then use the CLI: export AI_GATEWAY_API_KEY=abc123; ai-gateway-cli add-route --path /ml-predict --target http://model-service:8000. Verify with a curl request: curl -H "Authorization: Bearer abc123" http://gateway:8080/ml-predict -d '{"input": "data"}'.

  2. Secure and Monitor API: Secure an endpoint and monitor traffic by running: ai-gateway-cli secure --endpoint /chat --auth api-key --rate-limit 50/min. Then, query metrics: ai-gateway-cli metrics --endpoint /chat. In code, handle it as: ```python import requests; headers = {'Authorization': f'Bearer {os.environ["AI_GATEWAY_API_KEY"]}'}; requests.get('http://gateway:8080/api/v1/metrics', headers=headers)

Graph Relationships

  • Related to: aimlops (cluster), ai (tag), mlops (tag)
  • Depends on: authentication services for security
  • Used by: AI services for routing and monitoring
  • Integrates with: Kubernetes for deployment, Prometheus for metrics collection