0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ollama+agentでローカルAIエージェント

0
Posted at

ollama+agentでローカルAIエージェント

Qwen 3.6やGemma4など実用的なローカルLLMが出てきたので、フロンティアモデルの必要がない簡単な作業ならローカルで完結できるようになりました。そこで既存のAIエージェントをollamaを使ってローカルLLMを動かし、開発したいと思います。

ローカルLLMは高速なPCで動かしたいので、ollamaはsshトンネリングで動かすことにします。使えるAIエージェントは、Codex、Claude Code、OpenCode、GitHub Copilotです。

Codex CLI

次のコマンドでインストールする。

curl -fsSL https://chatgpt.com/codex/install.sh | sh

次のコマンドで動きます。

codex --oss -m gpt-oss:120b-cloud

Claude code

次のコマンドでインストールする。

curl -fsSL https://claude.ai/install.sh | bash

ollamaを使うために、環境変数を設定し、claude codeを実行する。

export ANTHROPIC_AUTH_TOKEN="ollama"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_BASE_URL="http://localhost:11434"
claude --model qwen3-coder:30b

ollamaがインストールされていれば

ollama launch claude --model qwen3-coder:30b

でも動く。しかし、ollamaが入っていないと動かない(sshトンネリングで動かす場合は使用できない)。

OpenCode

次のコマンドでインストールする。

curl -fsSL https://opencode.ai/install | bash

.opencode/opencode.jsonにollamaの設定を書く。

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen3.6:35b_agent": {
          "name": "qwen3.6:35b"
        },
          "qwen3.6:27b_agent": {
          "name": "qwen3.6:27b"
        }
      }
    }
  }
}

OpenCodeを実行し、ollamaのモデルを選ぶ。

GitHub Copilot

sshトンネリングすれば(ollamaがインストールされていれば)、Copilotが使用するモデルにollamaのモデルが記載される。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?