Skip to main content

Documentation Index

Fetch the complete documentation index at: https://kawax.biz/llms.txt

Use this file to discover all available pages before exploring further.

Runtime switching of GitHub tokens

Use this when you want to run Copilot CLI with a per-user GitHub token from Socialite or a similar authentication flow.
Personal Access Tokens need the Copilot Requests permission. The same requirement likely applies to Socialite-based user tokens. If you cannot get a usable Socialite token, ask users to provide a PAT directly.
This approach is available only in stdio mode. You cannot switch this in TCP mode because the Copilot CLI process stays running. If you set github_token or use_logged_in_user in TCP mode (cli_url), an error is raised.
The “Per-session GitHub token (v0.3.0+)” section below is available in TCP mode as well.

github_token option

This is an official SDK option. The SDK passes the token to CLI through COPILOT_SDK_AUTH_TOKEN.
use Revolution\Copilot\Facades\Copilot;

$config = array_merge(
    config('copilot'),
    [
        'github_token' => $user->github_token,
    ]
);

$response = Copilot::useStdio($config)->run(prompt: '...');
Copilot::stop(); // Dispose of the client carrying the user token

use_logged_in_user option

When you set github_token, use_logged_in_user is automatically set to false. This makes CLI ignore stored OAuth and gh CLI credentials and use only the explicit token. You can also set use_logged_in_user to true explicitly:
$config = [
    'github_token' => $user->github_token,
    'use_logged_in_user' => true, // Explicitly enabled
];
If you set use_logged_in_user to false without github_token, the SDK adds --no-auto-login, so CLI does not auto-login.

Per-session GitHub token (v0.3.0+)

Using the gitHubToken field in SessionConfig, you can specify a different GitHub token per session within the same CLI process (multi-tenant support). This token is passed as a parameter in the session.create JSON-RPC call, so it is available in both stdio mode and TCP mode. Even in TCP mode where the CLI is already running, you can switch tokens per session.
use Revolution\Copilot\Facades\Copilot;
use Revolution\Copilot\Types\SessionConfig;

$response = Copilot::run(
    prompt: '...',
    config: new SessionConfig(gitHubToken: $user->github_token),
);
TCP mode example:
// CLI server is already running (TCP mode)
// You can pass a different user token per session
$response = Copilot::useTcp(url: 'tcp://127.0.0.1:12345')->run(
    prompt: '...',
    config: new SessionConfig(gitHubToken: $user->github_token),
);
This works independently from the client-level github_token (the token used when launching the CLI process). Use this when you want to switch user tokens on a per-session basis.
For the latest updates, see the GitHub repository.
Last modified on April 25, 2026