サポートされているプロバイダー
| Provider | 型の値 | メモ |
|---|---|---|
| OpenAI | "openai" | OpenAI API と OpenAI と互換性のあるエンドポイント |
| Microsoft Foundry / Azure OpenAI | ||
"openai" または "azure" | ||
"openai"に/openai/v1/を使用する。ネイティブ Azure エンドポイントに"azure"を使用する | ||
| Anthropic | "anthropic" | クロード モデル |
| Ollama | "openai" | OpenAI 互換 API を使用したローカル モデル |
| マイクロソフト ファウンドリー ローカル | "openai" | OpenAI 互換 API を使用してデバイス上で AI モデルをローカルで実行する |
| その他の OpenAI 互換 | "openai" | vLLM、LiteLLM など |
クイック スタート: Microsoft Foundry
Microsoft Foundry は、企業向けの一般的な BYOK デプロイ ターゲットです。 完全な例を次に示します。
コード言語 navigation
Python
import asyncio
import os
from copilot import CopilotClient
from copilot.session import PermissionHandler
FOUNDRY_MODEL_URL = "https://<resource-name>.openai.azure.com/openai/v1/"
# Set FOUNDRY_API_KEY environment variable
async def main():
client = CopilotClient()
await client.start()
session = await client.create_session(on_permission_request=PermissionHandler.approve_all, model="gpt-5.2-codex", provider={
"type": "openai",
"base_url": FOUNDRY_MODEL_URL,
"wire_api": "responses", # Use "completions" for older models
"api_key": os.environ["FOUNDRY_API_KEY"],
})
done = asyncio.Event()
def on_event(event):
if event.type.value == "assistant.message":
print(event.data.content)
elif event.type.value == "session.idle":
done.set()
session.on(on_event)
await session.send("What is 2+2?")
await done.wait()
await session.disconnect()
await client.stop()
asyncio.run(main())
TypeScript
import { CopilotClient } from "@github/copilot-sdk";
const FOUNDRY_MODEL_URL = "https://<resource-name>.openai.azure.com/openai/v1/";
const client = new CopilotClient();
const session = await client.createSession({
model: "gpt-5.2-codex", // Your deployment name
provider: {
type: "openai",
baseUrl: FOUNDRY_MODEL_URL,
wireApi: "responses", // Use "completions" for older models
apiKey: process.env.FOUNDRY_API_KEY,
},
});
session.on("assistant.message", (event) => {
console.log(event.data.content);
});
await session.sendAndWait({ prompt: "What is 2+2?" });
await client.stop();
Go
package main
import (
"context"
"fmt"
"os"
copilot "github.com/github/copilot-sdk/go"
)
func main() {
ctx := context.Background()
client := copilot.NewClient(nil)
if err := client.Start(ctx); err != nil {
panic(err)
}
defer client.Stop()
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
Model: "gpt-5.2-codex", // Your deployment name
Provider: &copilot.ProviderConfig{
Type: "openai",
BaseURL: "https://<resource-name>.openai.azure.com/openai/v1/",
WireAPI: "responses", // Use "completions" for older models
APIKey: os.Getenv("FOUNDRY_API_KEY"),
},
})
if err != nil {
panic(err)
}
response, err := session.SendAndWait(ctx, copilot.MessageOptions{
Prompt: "What is 2+2?",
})
if err != nil {
panic(err)
}
if d, ok := response.Data.(*copilot.AssistantMessageData); ok {
fmt.Println(d.Content)
}
}
.NET
using GitHub.Copilot;
await using var client = new CopilotClient();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-5.2-codex", // Your deployment name
Provider = new ProviderConfig
{
Type = "openai",
BaseUrl = "https://<resource-name>.openai.azure.com/openai/v1/",
WireApi = "responses", // Use "completions" for older models
ApiKey = Environment.GetEnvironmentVariable("FOUNDRY_API_KEY"),
},
});
var response = await session.SendAndWaitAsync(new MessageOptions
{
Prompt = "What is 2+2?",
});
Console.WriteLine(response?.Data.Content);
Java
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
var client = new CopilotClient();
client.start().get();
var session = client.createSession(new SessionConfig()
.setModel("gpt-5.2-codex") // Your deployment name
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
.setProvider(new ProviderConfig()
.setType("openai")
.setBaseUrl("https://<resource-name>.openai.azure.com/openai/v1/")
.setWireApi("responses") // Use "completions" for older models
.setApiKey(System.getenv("FOUNDRY_API_KEY")))
).get();
var response = session.sendAndWait(new MessageOptions()
.setPrompt("What is 2+2?")).get();
System.out.println(response.getData().content());
client.stop().get();
プロバイダー構成リファレンス
ProviderConfig フィールド
| フィールド | タイプ | Description |
|---|---|---|
type | ||
"openai" | ||
| | | ||
"azure" | ||
| | | ||
"anthropic" | ||
プロバイダーの種類 (既定値: "openai") | ||
baseUrl / base_url | 文字列 | |
| 必須。 API エンドポイント URL | ||
apiKey / api_key | 文字列 | API キー (Ollama などのローカル プロバイダーの場合は省略可能) |
bearerToken / bearer_token | 文字列 | ベアラー トークン認証 (apiKey よりも優先されます) |
bearer / bearer_token_ | コールバック | ベアラー トークンをオンデマンドで返します ( apiKey と bearerTokenよりも優先されます) |
wireApi / wire_api | ||
"completions" | ||
| | | ||
"responses" | ||
広範なモデル互換性 (Chat Completions API) の "completions" を選択し、マルチターン状態管理、ツール名の指定、および推論のサポート (Responses API) の "responses" を選択します。 Anthropicモデルでは、この設定に関係なく、常に Messages API が使用されます。 | ||
azure.apiVersion / azure.api_version | 文字列 | Azure API バージョン。 設定すると、ランタイムはバージョン管理されたデプロイ ルートを使用します。省略すると、GA のバージョンレス v1 ルートが使用されます。 |
Wire API フォーマット形式
wireApi設定によって、使用する OpenAI API 形式が決まります。
"completions"(既定) - 広範なモデル互換性のためのチャット補完 API (/chat/completions)。"responses"- 複数ターン状態管理、ツールの名前空間、推論機能のサポートのための応答 API。
Anthropic モデルでは、この設定に関係なく、常に Anthropic Messages API が使用されます。
型固有の注記
OpenAI (type: "openai")
- OpenAI API と任意の OpenAI 互換エンドポイントで動作します
baseUrlは完全なパスを含める必要があります (例:https://api.openai.com/v1)
Azure (type: "azure")
- ネイティブ Azure OpenAI エンドポイントに使用する
baseUrlはホスト (例:https://my-resource.openai.azure.com) である必要があります- URL に
/openai/v1を含めないでください。SDK はパスの構築を処理します
アントロピック (type: "anthropic")
- Anthropic API への直接アクセスの場合
- Claude 固有の API 形式を使用します
構成例
OpenAI Direct
provider: {
type: "openai",
baseUrl: "https://api.openai.com/v1",
apiKey: process.env.OPENAI_API_KEY,
}
Azure OpenAI (ネイティブ Azure エンドポイント)
type: "azure"のエンドポイントに*.openai.azure.comを使用します。
provider: {
type: "azure",
baseUrl: "https://my-resource.openai.azure.com", // Just the host
apiKey: process.env.AZURE_OPENAI_KEY,
azure: {
apiVersion: "2024-10-21",
},
}
Microsoft Foundry (OpenAI 互換エンドポイント)
/openai/v1/ エンドポイントMicrosoft Foundry デプロイの場合は、次のtype: "openai"を使用します。
provider: {
type: "openai",
baseUrl: "https://<resource-name>.openai.azure.com/openai/v1/",
apiKey: process.env.FOUNDRY_API_KEY,
wireApi: "responses", // For GPT-5 series models
}
Ollama (ローカル)
provider: {
type: "openai",
baseUrl: "http://localhost:11434/v1",
// No apiKey needed for local Ollama
}