feat(ai): add xAI device OAuth and route grok-4.5 through Responses (#6651)
* feat(ai): add xAI device OAuth and route grok-4.5 through Responses Add xAI device-code OAuth alongside XAI_API_KEY. Route only grok-4.5 through Responses with low/medium/high reasoning; other xAI models stay on Completions. * fix(ai): tolerate xAI device-code interval 0 and correct token poll error label --------- Co-authored-by: Jaaneek <Jaaneek@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
36db3fa385
commit
5220aba619
@@ -97,11 +97,12 @@ export const XAI_MODELS = {
|
||||
"grok-4.5": {
|
||||
id: "grok-4.5",
|
||||
name: "Grok 4.5",
|
||||
api: "openai-completions",
|
||||
api: "openai-responses",
|
||||
provider: "xai",
|
||||
baseUrl: "https://api.x.ai/v1",
|
||||
compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":false},
|
||||
compat: {"supportsLongCacheRetention":false},
|
||||
reasoning: true,
|
||||
thinkingLevelMap: {"off":null,"minimal":null},
|
||||
input: ["text", "image"],
|
||||
cost: {
|
||||
input: 2,
|
||||
@@ -111,7 +112,7 @@ export const XAI_MODELS = {
|
||||
},
|
||||
contextWindow: 500000,
|
||||
maxTokens: 500000,
|
||||
} satisfies Model<"openai-completions">,
|
||||
} satisfies Model<"openai-responses">,
|
||||
"grok-build-0.1": {
|
||||
id: "grok-build-0.1",
|
||||
name: "Grok Build 0.1",
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
import { openAICompletionsApi } from "../api/openai-completions.lazy.ts";
|
||||
import { envApiKeyAuth } from "../auth/helpers.ts";
|
||||
import { openAIResponsesApi } from "../api/openai-responses.lazy.ts";
|
||||
import { envApiKeyAuth, lazyOAuth } from "../auth/helpers.ts";
|
||||
import { loadXaiOAuth } from "../auth/oauth/load.ts";
|
||||
import { createProvider, type Provider } from "../models.ts";
|
||||
import { XAI_MODELS } from "./xai.models.ts";
|
||||
|
||||
export function xaiProvider(): Provider<"openai-completions"> {
|
||||
export function xaiProvider(): Provider<"openai-completions" | "openai-responses"> {
|
||||
return createProvider({
|
||||
id: "xai",
|
||||
name: "xAI",
|
||||
baseUrl: "https://api.x.ai/v1",
|
||||
auth: { apiKey: envApiKeyAuth("xAI API key", ["XAI_API_KEY"]) },
|
||||
auth: {
|
||||
apiKey: envApiKeyAuth("xAI API key", ["XAI_API_KEY"]),
|
||||
oauth: lazyOAuth({ name: "xAI (Grok/X subscription)", load: loadXaiOAuth }),
|
||||
},
|
||||
models: Object.values(XAI_MODELS),
|
||||
api: openAICompletionsApi(),
|
||||
api: {
|
||||
"openai-completions": openAICompletionsApi(),
|
||||
"openai-responses": openAIResponsesApi(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user