Skip to content

Commit fa86123

Browse files
HavenDVclaude
andcommitted
feat: add Inworld as a custom provider
Inworld exposes an OpenAI-compatible LLM Router at `https://api.inworld.ai/v1/chat/completions` with access to many upstream chat models. Callers can now do: var openAi = CustomProviders.Inworld(jwt); The base constructor sends `Authorization: Bearer <value>`. Server-side callers who want Basic auth with the Portal-issued Base64 key should either supply a pre-minted JWT (see `InworldJwt.GenerateAsync` in tryAGI.Inworld) or configure an HttpClient that rewrites the scheme. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cd34dcf commit fa86123

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/libs/tryAGI.OpenAI/CustomProviders.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ public static class CustomProviders
136136
/// </summary>
137137
public const string SiliconFlowBaseUrl = "https://api.siliconflow.cn/v1";
138138

139+
/// <summary>
140+
/// https://docs.inworld.ai/api-reference/routerAPI/
141+
/// Inworld LLM Router exposes OpenAI-compatible chat completions over many upstream models.
142+
/// Expects `Authorization: Basic &lt;base64-api-key&gt;` — the Inworld Portal already Base64-encodes the key.
143+
/// </summary>
144+
public const string InworldBaseUrl = "https://api.inworld.ai/v1";
145+
139146
/// <summary>
140147
/// Creates an API to use for GitHub Models: https://github.com/marketplace/models
141148
/// </summary>
@@ -378,4 +385,19 @@ public static OpenAiClient SiliconFlow(string apiKey)
378385
{
379386
return new OpenAiClient(apiKey, baseUri: new Uri(SiliconFlowBaseUrl));
380387
}
388+
389+
/// <summary>
390+
/// Create an API to use for Inworld's LLM Router. Accepts either the
391+
/// Base64 Basic API key or a JWT Bearer token; the shipped OpenAI SDK
392+
/// sends the raw value as `Authorization: Bearer &lt;value&gt;`, so for
393+
/// server-side Basic usage callers should either supply a pre-minted JWT
394+
/// (see <c>InworldJwt.GenerateAsync</c> in <c>tryAGI.Inworld</c>) or
395+
/// configure a <see cref="System.Net.Http.HttpClient"/> that rewrites the
396+
/// scheme to `Basic`.
397+
/// </summary>
398+
/// <returns></returns>
399+
public static OpenAiClient Inworld(string apiKeyOrJwt)
400+
{
401+
return new OpenAiClient(apiKeyOrJwt, baseUri: new Uri(InworldBaseUrl));
402+
}
381403
}

0 commit comments

Comments
 (0)