ja ▾
キーを作成

Uncensored API、あなた自身の方法。

https://api.mistralapikeys.com/v1

開発者向け統合ガイド

ベースURLを置き換えるだけで既存のスタックに制限なしLLMを組み込みます。このガイドでは、認証、応答のストリーミング、OpenAI互換APIでのトークンコスト管理の正確な手順を解説します。

認証 & ベースURL

APIキーの生成はダッシュボードから開始します。当サービスではベースURLを HTTPS://api.mistralapikeys.com/v1 に設定する必要があります。キーはAuthorizationヘッダーにBearerトークンとして渡してください。Googleまたはメールアドレスによる電話番号不要のサインアップをサポートしています。

curl https://api.mistralapikeys.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Convert the python loop to rust syntax"}]
  }'

Chat Completionsエンドポイント

POST リクエストを /v1/chat/completions に送信します。テキスト生成にはモデルID「uncensored」を使用します。システムはroleとcontentフィールドを持つ標準的なメッセージ配列を受け入れます。入力トークンは1Mあたり$0.15、出力トークンは1Mあたり$0.50です。

from openai import OpenAI

client = OpenAI(base_url="https://api.mistralapikeys.com/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)

ストリーミングレスポンスとトークン数

ストリーミングを有効にするには stream を true に設定します。APIは部分的なチャンクを含むServer-Sent Eventsを返します。最終チャンクには正確な請求のための完全なトークン使用統計が含まれます。このアプローチは長い出力の知覚されるレイテンシーを削減します。

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.mistralapikeys.com/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

ストリーミング

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

数秒でキーを取得

サインアップしてキーをコピーし、ベースURLを更新します。完了です。

キーを作成ドキュメントを表示