Mistral AI
BetaMistral AI ↗は、Mistralの高度なAIモデルを使用して迅速に構築するのを支援します。
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/mistral
Mistral AIにリクエストを送信する際に必要なものは次のとおりです:
- AI Gateway アカウントID
- AI Gateway ゲートウェイ名
- Mistral AI APIトークン
- Mistral AI モデル名
新しいベースURLは、上記のデータを使用してこの構造になります:https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/mistral/。
その後、アクセスしたいエンドポイントを追加できます。例えば:v1/chat/completions
したがって、最終的なURLは次のようになります:https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/mistral/v1/chat/completions。
curl -X POST https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/mistral/v1/chat/completions \ --header 'content-type: application/json' \ --header 'Authorization: Bearer MISTRAL_TOKEN' \ --data '{ "model": "mistral-large-latest", "messages": [ { "role": "user", "content": "Cloudflareとは何ですか?" } ]}'@mistralai/mistralaiパッケージを使用している場合、エンドポイントを次のように設定できます:
import { Mistral } from "@mistralai/mistralai";
const client = new Mistral({ apiKey: MISTRAL_TOKEN, serverURL: `https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/mistral`,});
await client.chat.create({ model: "mistral-large-latest", messages: [ { role: "user", content: "Cloudflareとは何ですか?", }, ],});