はじめての Fugu × Codex セットアップガイド
AIやパソコンの専門知識がなくても大丈夫。上から順番に進めれば、Sakana AI の「Fugu」を Codex で使えるようになります。
このガイドでできるようになること
- Sakana AI が提供する AI「Fugu(フグ)」を使うための「鍵(API キー)」を手に入れる
- その Fugu を、コーディング用 AI ツール「Codex(コーデックス)」の中で動かす
所要時間の目安:だいたい15〜30分。難しい用語は、その都度やさしく説明します。
1. まず、言葉の意味をやさしく
最初に、このガイドに出てくる4つの言葉だけ押さえておきましょう。完璧に覚える必要はありません。
| 言葉 | やさしい説明 |
|---|---|
| Fugu(フグ) | Sakana AI が作った AI。ChatGPT や Claude の仲間で、文章を書いたり、質問に答えたり、プログラムを手伝ったりできます。 |
| Codex(コーデックス) | パソコンの中で AI に作業を頼める道具。本来は別の AI で動きますが、設定を変えると「Fugu」で動かせます。今回これを目指します。 |
| API キー | Fugu を使うための「あなた専用の鍵」。長い文字列です。これがないと Fugu は反応しません。パスワードと同じくらい大事に扱います。 |
| ターミナル | 文字でパソコンに命令する黒い画面。Mac は「ターミナル」、Windows は「PowerShell」や「WSL(Ubuntu)」がこれにあたります。 |
2. 全体の流れ(3ステップ)
- 鍵を作る … Sakana のサイトで API キーを発行します。
- 道具に鍵を教える … Codex に「Fugu を使う」設定を入れます。
- 使ってみる … Codex を起動すると、中身が Fugu になっています。
この3つだけです。途中の「確認テスト」や「Python から使う」は、やりたい人向けの寄り道なので飛ばしても構いません。
3. 準備するもの
- インターネットにつながったパソコン(Mac / Linux / Windows のいずれか)
- Sakana AI のアカウント(持っていなければ無料で作成できます)
- ターミナル(前の章で説明した「黒い画面」)が開けること
4. ステップ1:API キーを作る
STEP 1Fugu を使うための「鍵」を発行します。
- ブラウザで Sakana のコンソール(操作画面)を開きます:
https://console.sakana.ai - ログイン後、「API キー(API Keys)」のページを開きます:
https://console.sakana.ai/api-keys - 新しいキーを作成すると、長い文字列が表示されます。
- その文字列をコピーして、メモ帳などに貼り付けて保存します。
また、初期設定では Fugu は対応する複数のサービスを自動で使い分けます。特定のサービスだけに絞りたい上級者は、キー作成・編集時に「Fugu custom model pool」を有効にできます。よく分からなければそのままで大丈夫です。
5. ステップ2:キーが使えるか確認する(任意)
STEP 2 ・ 任意鍵がちゃんと働くか、軽くテストできます。飛ばしても問題ありませんが、最初に確認しておくと安心です。
ターミナルを開き、まず鍵を登録します。{your api key} の部分を、さっき保存した自分の鍵に置き換えてください(波カッコ { } は消します)。
export SAKANA_API_KEY={your api key}
続けて、次のコマンドを貼り付けて Enter を押します。Fugu に「strawberry に r はいくつ?」と質問しています。
curl -X POST https://api.sakana.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SAKANA_API_KEY" \
-d '{"model":"fugu","messages":[{"role":"user","content":"How many r in word strawberry"}]}'
AI からの返事(文章)が表示されれば、鍵は正しく使えています。
export は Mac / Linux / WSL 用の書き方です。Windows の PowerShell では、代わりに次のように書きます:$env:SAKANA_API_KEY = "ここに鍵"。迷ったら WSL(Ubuntu)の中で上のコマンドを使うのが簡単です。
6. ステップ3:Codex に Fugu を入れる
STEP 3いよいよ本番です。やり方は2通りあります。まずは A のかんたんインストールを試し、うまくいかない場合や Windows の場合は B の手動セットアップに進んでください。
A. かんたんインストール(おすすめ)
ターミナルに、次の1行を貼り付けて Enter を押すだけです。Fugu 用の Codex が自動で入ります。
curl -fsSL https://sakana.ai/fugu/install | bash
インストールが終わったら、次のコマンドで起動します。
codex-fugu
(Windows でも、WSL の Ubuntu を開いてその中でこの1行を実行すれば使えます。)
追加のオプションは、Sakana の公式リポジトリ(配布元)のコマンド一覧で確認できます。
B. 手動セットアップ
設定ファイルを自分で用意する方法です。少し手数は増えますが、中身をコピーして貼り付けるだけなので、内容を理解できなくても進められます。全部で5つの手順です。
① Codex を入れる(まだの場合)
Codex 本体がまだ無ければ入れます。<version> の部分は、Sakana Fugu が指定するバージョン番号(配布元の bundle.sh 内 BUNDLE_CODEX_VERSION)に置き換えます。
# インストーラーを使う場合(macOS / Linux、Node 不要):
curl -fsSL https://chatgpt.com/codex/install.sh | sh -s -- --release <version>
# または npm を使う場合:
npm i -g @openai/codex@<version>
② モデル一覧のファイル
次の内容を、まるごと ~/.codex/fugu.json という名前で保存します。長いですが、意味は分からなくて構いません。全部そのままコピーしてください。
{
"models": [
{
"slug": "fugu",
"display_name": "Fugu",
"context_window": 1000000,
"supported_reasoning_levels": [
{
"effort": "high",
"description": "Deep reasoning for complex problems"
},
{
"effort": "xhigh",
"description": "Go Brrrr for complex problems"
}
],
"shell_type": "shell_command",
"visibility": "list",
"supported_in_api": true,
"priority": 0,
"base_instructions": "Before recommending or running any command that could stop, restart, or replace the environment you are running in — e.g. `wsl --shutdown` / `wsl --terminate`, host or VM reboot, `systemctl`/service restarts of your runtime, or killing your own shell, container, or session processes — first determine whether you are executing inside that same environment. If you might be, do not run it yourself: warn the user explicitly that the command will end this session and your ability to help until it is restarted, give the exact recovery steps, and let the user run it manually when they are ready.\n\nNever force-kill processes by raw PID against arbitrary or unknown PID lists (e.g. `kill -9`, `Stop-Process -Force`, `taskkill /F`): the agent runtime depends on its own child processes, and force-killing them can permanently break the session. To stop a dev server or free a port, stop the owning task by name; otherwise ask the user before terminating any PID.",
"supports_reasoning_summaries": false,
"default_reasoning_summary": "none",
"support_verbosity": false,
"default_verbosity": null,
"apply_patch_tool_type": "freeform",
"input_modalities": [
"text",
"image"
],
"truncation_policy": {
"mode": "tokens",
"limit": 10000
},
"supports_parallel_tool_calls": true,
"experimental_supported_tools": []
},
{
"slug": "fugu-ultra",
"display_name": "Fugu Ultra",
"context_window": 1000000,
"supported_reasoning_levels": [
{
"effort": "high",
"description": "Deep reasoning for complex problems"
},
{
"effort": "xhigh",
"description": "Go Brrrr for complex problems"
}
],
"shell_type": "shell_command",
"visibility": "list",
"supported_in_api": true,
"priority": 1,
"base_instructions": "Before recommending or running any command that could stop, restart, or replace the environment you are running in — e.g. `wsl --shutdown` / `wsl --terminate`, host or VM reboot, `systemctl`/service restarts of your runtime, or killing your own shell, container, or session processes — first determine whether you are executing inside that same environment. If you might be, do not run it yourself: warn the user explicitly that the command will end this session and your ability to help until it is restarted, give the exact recovery steps, and let the user run it manually when they are ready.\n\nNever force-kill processes by raw PID against arbitrary or unknown PID lists (e.g. `kill -9`, `Stop-Process -Force`, `taskkill /F`): the agent runtime depends on its own child processes, and force-killing them can permanently break the session. To stop a dev server or free a port, stop the owning task by name; otherwise ask the user before terminating any PID.",
"supports_reasoning_summaries": true,
"default_reasoning_summary": "none",
"support_verbosity": false,
"default_verbosity": null,
"apply_patch_tool_type": "freeform",
"input_modalities": [
"text",
"image"
],
"truncation_policy": {
"mode": "tokens",
"limit": 10000
},
"supports_parallel_tool_calls": true,
"experimental_supported_tools": []
}
]
}
③ プロファイル(基本設定)のファイル
次の内容を ~/.codex/fugu.config.toml として保存します。
model = "fugu"
model_reasoning_effort = "high"
model_provider = "sakana"
model_catalog_json = "~/.codex/fugu.json"
[features]
image_generation = false
apps = false
④ 接続先(プロバイダー)のファイル
次の内容を ~/.codex/config.toml として保存します。
[model_providers.sakana]
name = "Sakana API"
base_url = "https://api.sakana.ai/v1"
env_key = "SAKANA_API_KEY"
wire_api = "responses"
stream_idle_timeout_ms = 7200000
# keep slow turns alive past Codex's ~5-min idle default
stream_max_retries = 5
# reconnect a dropped stream rather than failing the turn
request_max_retries = 4
# retry a transient HTTP failure rather than failing the turn
stream_idle_timeout_ms など)は、通信が途切れにくくする工夫です。AI が長く考えているときに途中で止まらないようにし、もし途切れても自動でつなぎ直します。Fugu は何度送り直しても安全な作りなので、入れておいて問題ありません。なお、このファイルはホーム以外に
{作業フォルダ}/.codex/config.toml として置くこともできます。
⑤ Codex を起動
準備完了です。次のコマンドで起動します({your api key} は自分の鍵に置き換え)。
SAKANA_API_KEY={your api key} codex -p fugu
7. ステップ4:Codex を起動して使う
STEP 4起動すると、最初から Fugu が選ばれています。あとは、やってほしいことを日本語や英語で書いて伝えるだけです。
- モデルを切り替えたいときは、Codex の中で
/modelと打ちます。 - 選べるモデルは2種類です。下の表を参考にしてください。
| モデル名 | 特徴 |
|---|---|
fugu | ふだん使い向け。複数のサービスを自動で使い分けて答えます。 |
fugu-ultra | より深く考えるタイプ。難しい問題向け。返事に時間がかかることがあります。 |
high(高)と xhigh(さらに高、別名 max)の2段階で指定できます。難しい作業ほど深い方が向いていますが、その分ゆっくりになります。
8. おまけ:プログラム(Python)から使う
自分でプログラムを書く人向けの寄り道です。不要なら飛ばして大丈夫です。
Fugu は ChatGPT などと同じ「OpenAI 形式」に対応しているので、よく知られた書き方でそのまま呼び出せます。
from openai import OpenAI
api_key = "YOUR_API_KEY"
client = OpenAI(
base_url="https://api.sakana.ai/v1",
api_key=api_key
)
response = client.responses.create(
model="fugu-ultra",
input="Write a concise explanation of how TLS works",
timeout=120.0,
)
print(response.output_text)
fugu-ultra のような重い作業では、待ち時間(タイムアウト)を長めにしておくと安心です(例では120秒)。考える深さは reasoning.effort(例:effort="high")で指定できます。
9. 困ったときは
- ❑ 鍵が反応しない/エラーが出る … 鍵の文字列に余分なスペースや改行が混じっていないか確認。波カッコ
{ }を消し忘れていないかも確認します。 - ❑ かんたんインストールが失敗する(Windows) … 1行インストールは Mac / Linux 専用です。WSL(Ubuntu)の中で実行するか、「B. 手動セットアップ」に切り替えます。
- ❑ 返事が途中で止まる … 手動セットアップ④の「通信を途切れにくくする3行」が入っているか確認します。
- ❑ 同じところで3回つまずいた … 無理に進めず、いったん手を止めて、エラーメッセージをそのまま控えておきましょう。
10. 用語集
| 用語 | 意味 |
|---|---|
| API | ソフト同士がデータをやりとりするための窓口。ここでは Fugu に質問を送り、答えを受け取る仕組み。 |
| API キー | その窓口を使うための、あなた専用の鍵(長い文字列)。他人に見せない。 |
| ベース URL | 接続先の住所。Fugu では https://api.sakana.ai/v1。 |
| ターミナル / シェル | 文字で命令を打つ画面。Mac=ターミナル、Windows=PowerShell や WSL。 |
| WSL | Windows の中で Linux(Ubuntu)を動かすしくみ。Mac / Linux 向けの手順を Windows で使えるようになる。 |
| curl(カール) | ターミナルから通信して、データを送受信する道具。動作確認に使う。 |
| responses / chat completions | Fugu との会話のやり方(規格)の名前。新しい連携には responses が向く。 |