Models, tools, and accounts
Scope: ServerRpc (server-wide operations tied to the Client) For an overview of RPC and the list of all RPC pages, see RPC.Copilot::client()->rpc()->ping();
// models
Copilot::client()->rpc()->models()->list();
// Get with a per-session GitHub token
Copilot::client()->rpc()->models()->list(new ModelsListRequest(gitHubToken: $token));
// Get the token price units for models. Pass the same account selection info as models.list
$priceUnits = Copilot::client()->rpc()->models()->listTokenPriceUnits(
new ModelsListTokenPriceUnitsRequest(gitHubToken: $token),
);
// $priceUnits->units has modelId and a unit of TokenPriceUnit|string
foreach ($priceUnits->units as $priceUnit) {
if ($priceUnit->unit === TokenPriceUnit::NanoAiu) {
// To convert nano-AIU to AI Credits, divide by 1,000,000,000
}
}
// Built-in model catalog
Copilot::client()->rpc()->models()->getBuiltInCatalog();
// tools
Copilot::client()->rpc()->tools()->list();
// account
Copilot::client()->rpc()->account()->getQuota();
// Get with a per-session GitHub token
Copilot::client()->rpc()->account()->getQuota(new AccountGetQuotaRequest(gitHubToken: $token));
// Resolve an absolute URL from the configured GitHub host name (no authentication required)
$hostUrl = Copilot::client()->rpc()->account()->getHostUrl([
'copilotGhHost' => 'github.example.com',
])->url;
// Enroll an authenticated identity, without credentials, in Copilot Free
$enrollment = Copilot::client()->rpc()->account()->subscribeCopilotFree([
'identity' => [
'type' => 'token',
'host' => 'https://github.com',
'login' => 'octocat',
],
]);
// $enrollment->kind / $enrollment->status / $enrollment->message
// tools largeOutput (experimental: clean up expired large tool outputs)
Copilot::client()->rpc()->tools()->largeOutput()->cleanup();