Compare commits
2 Commits
de6a21fb5a
...
941894761a
| Author | SHA1 | Date | |
|---|---|---|---|
| 941894761a | |||
| 5fb914dbc8 |
19
OpenRouter/OpenRouterHeaders.cs
Normal file
19
OpenRouter/OpenRouterHeaders.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace AnchorCli.OpenRouter;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides extension methods for adding OpenRouter-specific HTTP headers.
|
||||||
|
/// </summary>
|
||||||
|
public static class OpenRouterHeaders
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Applies the required OpenRouter headers to the specified HttpClient.
|
||||||
|
/// </summary>
|
||||||
|
public static void ApplyTo(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("HTTP-Referer", "https://git.technopunk.space/tomi/AnchorCli");
|
||||||
|
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-OpenRouter-Title", "Anchor CLI");
|
||||||
|
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-OpenRouter-Categories", "cli-agent");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,11 @@ internal sealed class PricingProvider
|
|||||||
private static readonly HttpClient Http = new();
|
private static readonly HttpClient Http = new();
|
||||||
private Dictionary<string, ModelInfo>? _models;
|
private Dictionary<string, ModelInfo>? _models;
|
||||||
|
|
||||||
|
static PricingProvider()
|
||||||
|
{
|
||||||
|
OpenRouterHeaders.ApplyTo(Http);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches the full model list from OpenRouter (cached after first call).
|
/// Fetches the full model list from OpenRouter (cached after first call).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -88,9 +88,13 @@ AnsiConsole.Write(infoTable);
|
|||||||
AnsiConsole.WriteLine();
|
AnsiConsole.WriteLine();
|
||||||
|
|
||||||
// ── Build the chat client with tool-calling support ─────────────────────
|
// ── Build the chat client with tool-calling support ─────────────────────
|
||||||
|
var httpClient = new HttpClient();
|
||||||
|
OpenRouterHeaders.ApplyTo(httpClient);
|
||||||
|
|
||||||
var openAiClient = new OpenAIClient(new ApiKeyCredential(apiKey), new OpenAIClientOptions
|
var openAiClient = new OpenAIClient(new ApiKeyCredential(apiKey), new OpenAIClientOptions
|
||||||
{
|
{
|
||||||
Endpoint = new Uri(endpoint)
|
Endpoint = new Uri(endpoint),
|
||||||
|
Transport = new System.ClientModel.Primitives.HttpClientPipelineTransport(httpClient)
|
||||||
});
|
});
|
||||||
|
|
||||||
IChatClient innerClient = openAiClient.GetChatClient(model).AsIChatClient();
|
IChatClient innerClient = openAiClient.GetChatClient(model).AsIChatClient();
|
||||||
|
|||||||
@@ -33,9 +33,10 @@ internal static class SetupTui
|
|||||||
var models = new List<(string Value, string Description)>
|
var models = new List<(string Value, string Description)>
|
||||||
{
|
{
|
||||||
("qwen/qwen3.5-397b-a17b", "smart, expensive"),
|
("qwen/qwen3.5-397b-a17b", "smart, expensive"),
|
||||||
("qwen/qwen3.5-35b-a3b", "cheapest"),
|
("qwen/qwen3.5-122b-a10b", "faster"),
|
||||||
("qwen/qwen3.5-27b", "fast"),
|
("qwen/qwen3.5-27b", "fast"),
|
||||||
("qwen/qwen3.5-122b-a10b", "smart"),
|
("qwen/qwen3.5-Flash", "cloud, fast"),
|
||||||
|
("qwen/qwen3.5-Plus", "cloud, smart"),
|
||||||
("Custom...", "")
|
("Custom...", "")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user