From 61943b10c7db8a3d56a68ffda17e5576b2d653c6 Mon Sep 17 00:00:00 2001 From: Riccardo Giorato Date: Sun, 25 Jan 2026 20:32:12 +0100 Subject: [PATCH 1/3] Add Together AI model support with Llama, DeepSeek, and Qwen models --- src/agents/together-models.ts | 121 ++++++++++++++++++ src/cli/program.smoke.test.ts | 6 + src/cli/program/register.onboard.ts | 3 +- src/commands/auth-choice-options.test.ts | 13 ++ src/commands/auth-choice-options.ts | 5 + .../auth-choice.apply.api-providers.ts | 64 +++++++++ .../auth-choice.preferred-provider.ts | 1 + src/commands/onboard-auth.config-core.ts | 75 +++++++++++ src/commands/onboard-auth.credentials.ts | 13 ++ src/commands/onboard-auth.ts | 10 ++ .../local/auth-choice.ts | 21 +++ src/commands/onboard-types.ts | 2 + 12 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 src/agents/together-models.ts diff --git a/src/agents/together-models.ts b/src/agents/together-models.ts new file mode 100644 index 000000000..a16e96837 --- /dev/null +++ b/src/agents/together-models.ts @@ -0,0 +1,121 @@ +import type { ModelDefinitionConfig } from "../config/types.js"; + +export const TOGETHER_BASE_URL = "https://api.together.xyz/v1"; +export const TOGETHER_DEFAULT_MODEL_ID = "meta-llama/Llama-3.3-70B-Instruct-Turbo"; +export const TOGETHER_DEFAULT_MODEL_REF = `together/${TOGETHER_DEFAULT_MODEL_ID}`; + +export const TOGETHER_MODEL_CATALOG = [ + { + id: "meta-llama/Llama-3.3-70B-Instruct-Turbo", + name: "Llama 3.3 70B Instruct Turbo", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.88, + output: 0.88, + cacheRead: 0.88, + cacheWrite: 0.88, + }, + }, + { + id: "meta-llama/Llama-4-Scout-17B-16E-Instruct", + name: "Llama 4 Scout 17B 16E Instruct", + reasoning: false, + input: ["text", "image"], + contextWindow: 10000000, + maxTokens: 32768, + cost: { + input: 0.18, + output: 0.59, + cacheRead: 0.18, + cacheWrite: 0.18, + }, + }, + { + id: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", + name: "Llama 4 Maverick 17B 128E Instruct FP8", + reasoning: false, + input: ["text", "image"], + contextWindow: 20000000, + maxTokens: 32768, + cost: { + input: 0.27, + output: 0.85, + cacheRead: 0.27, + cacheWrite: 0.27, + }, + }, + { + id: "deepseek-ai/DeepSeek-V3.1", + name: "DeepSeek V3.1", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.6, + output: 1.25, + cacheRead: 0.6, + cacheWrite: 0.6, + }, + }, + { + id: "deepseek-ai/DeepSeek-R1", + name: "DeepSeek R1", + reasoning: true, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 3.0, + output: 7.0, + cacheRead: 3.0, + cacheWrite: 3.0, + }, + }, + { + id: "Qwen/Qwen2.5-72B-Instruct-Turbo", + name: "Qwen 2.5 72B Instruct Turbo", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.35, + output: 0.8, + cacheRead: 0.35, + cacheWrite: 0.35, + }, + }, + { + id: "mistralai/Mixtral-8x7B-Instruct-v0.1", + name: "Mixtral 8x7B Instruct v0.1", + reasoning: false, + input: ["text"], + contextWindow: 32768, + maxTokens: 8192, + cost: { + input: 0.6, + output: 0.6, + cacheRead: 0.6, + cacheWrite: 0.6, + }, + }, +] as const; + +export function buildTogetherModelDefinition( + model: (typeof TOGETHER_MODEL_CATALOG)[number], +): ModelDefinitionConfig { + return { + id: model.id, + name: model.name, + api: "openai-completions", + reasoning: model.reasoning, + input: [...model.input], + cost: model.cost, + contextWindow: model.contextWindow, + maxTokens: model.maxTokens, + }; +} diff --git a/src/cli/program.smoke.test.ts b/src/cli/program.smoke.test.ts index f6b155554..894c70ff5 100644 --- a/src/cli/program.smoke.test.ts +++ b/src/cli/program.smoke.test.ts @@ -164,6 +164,12 @@ describe("cli program (smoke)", () => { key: "sk-moonshot-test", field: "moonshotApiKey", }, + { + authChoice: "together-api-key", + flag: "--together-api-key", + key: "sk-together-test", + field: "togetherApiKey", + }, { authChoice: "kimi-code-api-key", flag: "--kimi-code-api-key", diff --git a/src/cli/program/register.onboard.ts b/src/cli/program/register.onboard.ts index 281464b6f..43a58be4f 100644 --- a/src/cli/program/register.onboard.ts +++ b/src/cli/program/register.onboard.ts @@ -52,7 +52,7 @@ export function registerOnboardCommand(program: Command) { .option("--mode ", "Wizard mode: local|remote") .option( "--auth-choice ", - "Auth: setup-token|claude-cli|token|chutes|openai-codex|openai-api-key|openrouter-api-key|ai-gateway-api-key|moonshot-api-key|kimi-code-api-key|synthetic-api-key|codex-cli|gemini-api-key|zai-api-key|apiKey|minimax-api|minimax-api-lightning|opencode-zen|skip", + "Auth: setup-token|claude-cli|token|chutes|openai-codex|openai-api-key|openrouter-api-key|ai-gateway-api-key|moonshot-api-key|kimi-code-api-key|synthetic-api-key|together-api-key|codex-cli|gemini-api-key|zai-api-key|apiKey|minimax-api|minimax-api-lightning|opencode-zen|skip", ) .option( "--token-provider ", @@ -74,6 +74,7 @@ export function registerOnboardCommand(program: Command) { .option("--zai-api-key ", "Z.AI API key") .option("--minimax-api-key ", "MiniMax API key") .option("--synthetic-api-key ", "Synthetic API key") + .option("--together-api-key ", "Together AI API key") .option("--opencode-zen-api-key ", "OpenCode Zen API key") .option("--gateway-port ", "Gateway port") .option("--gateway-bind ", "Gateway bind: loopback|tailnet|lan|auto|custom") diff --git a/src/commands/auth-choice-options.test.ts b/src/commands/auth-choice-options.test.ts index db529761f..69b6fb370 100644 --- a/src/commands/auth-choice-options.test.ts +++ b/src/commands/auth-choice-options.test.ts @@ -101,6 +101,7 @@ describe("buildAuthChoiceOptions", () => { expect(options.some((opt) => opt.value === "moonshot-api-key")).toBe(true); expect(options.some((opt) => opt.value === "kimi-code-api-key")).toBe(true); + expect(options.some((opt) => opt.value === "together-api-key")).toBe(true); }); it("includes Vercel AI Gateway auth choice", () => { @@ -115,6 +116,18 @@ describe("buildAuthChoiceOptions", () => { expect(options.some((opt) => opt.value === "ai-gateway-api-key")).toBe(true); }); + it("includes Together AI auth choice", () => { + const store: AuthProfileStore = { version: 1, profiles: {} }; + const options = buildAuthChoiceOptions({ + store, + includeSkip: false, + includeClaudeCliIfMissing: true, + platform: "darwin", + }); + + expect(options.some((opt) => opt.value === "together-api-key")).toBe(true); + }); + it("includes Synthetic auth choice", () => { const store: AuthProfileStore = { version: 1, profiles: {} }; const options = buildAuthChoiceOptions({ diff --git a/src/commands/auth-choice-options.ts b/src/commands/auth-choice-options.ts index f13eef365..42139d3cd 100644 --- a/src/commands/auth-choice-options.ts +++ b/src/commands/auth-choice-options.ts @@ -202,6 +202,11 @@ export function buildAuthChoiceOptions(params: { label: "Venice AI API key", hint: "Privacy-focused inference (uncensored models)", }); + options.push({ + value: "together-api-key", + label: "Together AI API key", + hint: "Access to Llama, DeepSeek, Qwen, and more open models", + }); options.push({ value: "github-copilot", label: "GitHub Copilot (GitHub device login)", diff --git a/src/commands/auth-choice.apply.api-providers.ts b/src/commands/auth-choice.apply.api-providers.ts index 8be02008b..1efbfbf74 100644 --- a/src/commands/auth-choice.apply.api-providers.ts +++ b/src/commands/auth-choice.apply.api-providers.ts @@ -23,6 +23,8 @@ import { applyOpenrouterProviderConfig, applySyntheticConfig, applySyntheticProviderConfig, + applyTogetherConfig, + applyTogetherProviderConfig, applyVeniceConfig, applyVeniceProviderConfig, applyVercelAiGatewayConfig, @@ -32,6 +34,7 @@ import { MOONSHOT_DEFAULT_MODEL_REF, OPENROUTER_DEFAULT_MODEL_REF, SYNTHETIC_DEFAULT_MODEL_REF, + TOGETHER_DEFAULT_MODEL_REF, VENICE_DEFAULT_MODEL_REF, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF, setGeminiApiKey, @@ -40,6 +43,7 @@ import { setOpencodeZenApiKey, setOpenrouterApiKey, setSyntheticApiKey, + setTogetherApiKey, setVeniceApiKey, setVercelAiGatewayApiKey, setZaiApiKey, @@ -83,6 +87,8 @@ export async function applyAuthChoiceApiProviders( authChoice = "synthetic-api-key"; } else if (params.opts.tokenProvider === "venice") { authChoice = "venice-api-key"; + } else if (params.opts.tokenProvider === "together") { + authChoice = "together-api-key"; } else if (params.opts.tokenProvider === "opencode") { authChoice = "opencode-zen"; } @@ -579,5 +585,63 @@ export async function applyAuthChoiceApiProviders( return { config: nextConfig, agentModelOverride }; } + if (authChoice === "together-api-key") { + let hasCredential = false; + + if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "together") { + await setTogetherApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir); + hasCredential = true; + } + + if (!hasCredential) { + await params.prompter.note( + [ + "Together AI provides access to leading open-source models including Llama, DeepSeek, Qwen, and more.", + "Get your API key at: https://api.together.xyz/settings/api-keys", + ].join("\n"), + "Together AI", + ); + } + + const envKey = resolveEnvApiKey("together"); + if (envKey) { + const useExisting = await params.prompter.confirm({ + message: `Use existing TOGETHER_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`, + initialValue: true, + }); + if (useExisting) { + await setTogetherApiKey(envKey.apiKey, params.agentDir); + hasCredential = true; + } + } + if (!hasCredential) { + const key = await params.prompter.text({ + message: "Enter Together AI API key", + validate: validateApiKeyInput, + }); + await setTogetherApiKey(normalizeApiKeyInput(String(key)), params.agentDir); + } + nextConfig = applyAuthProfileConfig(nextConfig, { + profileId: "together:default", + provider: "together", + mode: "api_key", + }); + { + const applied = await applyDefaultModelChoice({ + config: nextConfig, + setDefaultModel: params.setDefaultModel, + defaultModel: TOGETHER_DEFAULT_MODEL_REF, + applyDefaultConfig: applyTogetherConfig, + applyProviderConfig: applyTogetherProviderConfig, + noteDefault: TOGETHER_DEFAULT_MODEL_REF, + noteAgentModel, + prompter: params.prompter, + }); + nextConfig = applied.config; + agentModelOverride = applied.agentModelOverride ?? agentModelOverride; + } + return { config: nextConfig, agentModelOverride }; + } + return null; } diff --git a/src/commands/auth-choice.preferred-provider.ts b/src/commands/auth-choice.preferred-provider.ts index 6fe26b59a..2340002df 100644 --- a/src/commands/auth-choice.preferred-provider.ts +++ b/src/commands/auth-choice.preferred-provider.ts @@ -20,6 +20,7 @@ const PREFERRED_PROVIDER_BY_AUTH_CHOICE: Partial> = { "zai-api-key": "zai", "synthetic-api-key": "synthetic", "venice-api-key": "venice", + "together-api-key": "together", "github-copilot": "github-copilot", "copilot-proxy": "copilot-proxy", "minimax-cloud": "minimax", diff --git a/src/commands/onboard-auth.config-core.ts b/src/commands/onboard-auth.config-core.ts index 0d3a8523a..17ad16a2e 100644 --- a/src/commands/onboard-auth.config-core.ts +++ b/src/commands/onboard-auth.config-core.ts @@ -4,6 +4,11 @@ import { SYNTHETIC_DEFAULT_MODEL_REF, SYNTHETIC_MODEL_CATALOG, } from "../agents/synthetic-models.js"; +import { + buildTogetherModelDefinition, + TOGETHER_BASE_URL, + TOGETHER_MODEL_CATALOG, +} from "../agents/together-models.js"; import { buildVeniceModelDefinition, VENICE_BASE_URL, @@ -13,6 +18,7 @@ import { import type { ClawdbotConfig } from "../config/config.js"; import { OPENROUTER_DEFAULT_MODEL_REF, + TOGETHER_DEFAULT_MODEL_REF, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF, ZAI_DEFAULT_MODEL_REF, } from "./onboard-auth.credentials.js"; @@ -411,6 +417,75 @@ export function applyVeniceConfig(cfg: ClawdbotConfig): ClawdbotConfig { }; } +export function applyTogetherProviderConfig(cfg: ClawdbotConfig): ClawdbotConfig { + const models = { ...cfg.agents?.defaults?.models }; + models[TOGETHER_DEFAULT_MODEL_REF] = { + ...models[TOGETHER_DEFAULT_MODEL_REF], + alias: models[TOGETHER_DEFAULT_MODEL_REF]?.alias ?? "Together AI", + }; + + const providers = { ...cfg.models?.providers }; + const existingProvider = providers.together; + const existingModels = Array.isArray(existingProvider?.models) ? existingProvider.models : []; + const togetherModels = TOGETHER_MODEL_CATALOG.map(buildTogetherModelDefinition); + const mergedModels = [ + ...existingModels, + ...togetherModels.filter( + (model) => !existingModels.some((existing) => existing.id === model.id), + ), + ]; + const { apiKey: existingApiKey, ...existingProviderRest } = (existingProvider ?? {}) as Record< + string, + unknown + > as { apiKey?: string }; + const resolvedApiKey = typeof existingApiKey === "string" ? existingApiKey : undefined; + const normalizedApiKey = resolvedApiKey?.trim(); + providers.together = { + ...existingProviderRest, + baseUrl: TOGETHER_BASE_URL, + api: "openai-completions", + ...(normalizedApiKey ? { apiKey: normalizedApiKey } : {}), + models: mergedModels.length > 0 ? mergedModels : togetherModels, + }; + + return { + ...cfg, + agents: { + ...cfg.agents, + defaults: { + ...cfg.agents?.defaults, + models, + }, + }, + models: { + mode: cfg.models?.mode ?? "merge", + providers, + }, + }; +} + +export function applyTogetherConfig(cfg: ClawdbotConfig): ClawdbotConfig { + const next = applyTogetherProviderConfig(cfg); + const existingModel = next.agents?.defaults?.model; + return { + ...next, + agents: { + ...next.agents, + defaults: { + ...next.agents?.defaults, + model: { + ...(existingModel && "fallbacks" in (existingModel as Record) + ? { + fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks, + } + : undefined), + primary: TOGETHER_DEFAULT_MODEL_REF, + }, + }, + }, + }; +} + export function applyAuthProfileConfig( cfg: ClawdbotConfig, params: { diff --git a/src/commands/onboard-auth.credentials.ts b/src/commands/onboard-auth.credentials.ts index 0c7dff409..e0cb09d11 100644 --- a/src/commands/onboard-auth.credentials.ts +++ b/src/commands/onboard-auth.credentials.ts @@ -115,6 +115,7 @@ export async function setVeniceApiKey(key: string, agentDir?: string) { export const ZAI_DEFAULT_MODEL_REF = "zai/glm-4.7"; export const OPENROUTER_DEFAULT_MODEL_REF = "openrouter/auto"; export const VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF = "vercel-ai-gateway/anthropic/claude-opus-4.5"; +export const TOGETHER_DEFAULT_MODEL_REF = "together/meta-llama/Llama-3.3-70B-Instruct-Turbo"; export async function setZaiApiKey(key: string, agentDir?: string) { // Write to resolved agent dir so gateway finds credentials on startup. @@ -164,3 +165,15 @@ export async function setOpencodeZenApiKey(key: string, agentDir?: string) { agentDir: resolveAuthAgentDir(agentDir), }); } + +export async function setTogetherApiKey(key: string, agentDir?: string) { + upsertAuthProfile({ + profileId: "together:default", + credential: { + type: "api_key", + provider: "together", + key, + }, + agentDir: resolveAuthAgentDir(agentDir), + }); +} diff --git a/src/commands/onboard-auth.ts b/src/commands/onboard-auth.ts index b122d89cf..555093765 100644 --- a/src/commands/onboard-auth.ts +++ b/src/commands/onboard-auth.ts @@ -13,6 +13,8 @@ export { applyOpenrouterProviderConfig, applySyntheticConfig, applySyntheticProviderConfig, + applyTogetherConfig, + applyTogetherProviderConfig, applyVeniceConfig, applyVeniceProviderConfig, applyVercelAiGatewayConfig, @@ -42,6 +44,7 @@ export { setOpencodeZenApiKey, setOpenrouterApiKey, setSyntheticApiKey, + setTogetherApiKey, setVeniceApiKey, setVercelAiGatewayApiKey, setZaiApiKey, @@ -65,3 +68,10 @@ export { MOONSHOT_DEFAULT_MODEL_ID, MOONSHOT_DEFAULT_MODEL_REF, } from "./onboard-auth.models.js"; +export { + buildTogetherModelDefinition, + TOGETHER_BASE_URL, + TOGETHER_DEFAULT_MODEL_ID, + TOGETHER_DEFAULT_MODEL_REF, + TOGETHER_MODEL_CATALOG, +} from "../agents/together-models.js"; diff --git a/src/commands/onboard-non-interactive/local/auth-choice.ts b/src/commands/onboard-non-interactive/local/auth-choice.ts index 6762fb7d2..3ff2894a0 100644 --- a/src/commands/onboard-non-interactive/local/auth-choice.ts +++ b/src/commands/onboard-non-interactive/local/auth-choice.ts @@ -20,6 +20,7 @@ import { applyOpencodeZenConfig, applyOpenrouterConfig, applySyntheticConfig, + applyTogetherConfig, applyVercelAiGatewayConfig, applyZaiConfig, setAnthropicApiKey, @@ -30,6 +31,7 @@ import { setOpencodeZenApiKey, setOpenrouterApiKey, setSyntheticApiKey, + setTogetherApiKey, setVercelAiGatewayApiKey, setZaiApiKey, } from "../../onboard-auth.js"; @@ -353,6 +355,25 @@ export async function applyNonInteractiveAuthChoice(params: { return applyOpencodeZenConfig(nextConfig); } + if (authChoice === "together-api-key") { + const resolved = await resolveNonInteractiveApiKey({ + provider: "together", + cfg: baseConfig, + flagValue: opts.togetherApiKey, + flagName: "--together-api-key", + envVar: "TOGETHER_API_KEY", + runtime, + }); + if (!resolved) return null; + if (resolved.source !== "profile") await setTogetherApiKey(resolved.key); + nextConfig = applyAuthProfileConfig(nextConfig, { + profileId: "together:default", + provider: "together", + mode: "api_key", + }); + return applyTogetherConfig(nextConfig); + } + if ( authChoice === "oauth" || authChoice === "chutes" || diff --git a/src/commands/onboard-types.ts b/src/commands/onboard-types.ts index 84c15afc4..e31611d30 100644 --- a/src/commands/onboard-types.ts +++ b/src/commands/onboard-types.ts @@ -17,6 +17,7 @@ export type AuthChoice = | "kimi-code-api-key" | "synthetic-api-key" | "venice-api-key" + | "together-api-key" | "codex-cli" | "apiKey" | "gemini-api-key" @@ -70,6 +71,7 @@ export type OnboardOptions = { minimaxApiKey?: string; syntheticApiKey?: string; veniceApiKey?: string; + togetherApiKey?: string; opencodeZenApiKey?: string; gatewayPort?: number; gatewayBind?: GatewayBind; From 59247b52cf18ecc5f947cdd9a8926ad43c431a26 Mon Sep 17 00:00:00 2001 From: Riccardo Giorato Date: Sun, 25 Jan 2026 20:47:27 +0100 Subject: [PATCH 2/3] Add Together AI provider with API key auth and model support --- docs/providers/index.md | 1 + docs/providers/together.md | 62 ++++++++++++++++++++++++++++++++++++++ src/agents/model-auth.ts | 1 + 3 files changed, 64 insertions(+) create mode 100644 docs/providers/together.md diff --git a/docs/providers/index.md b/docs/providers/index.md index c4f020192..0bc1f4ae3 100644 --- a/docs/providers/index.md +++ b/docs/providers/index.md @@ -38,6 +38,7 @@ See [Venice AI](/providers/venice). - [Qwen (OAuth)](/providers/qwen) - [OpenRouter](/providers/openrouter) - [Vercel AI Gateway](/providers/vercel-ai-gateway) +- [Together AI](/providers/together) - [Moonshot AI (Kimi + Kimi Code)](/providers/moonshot) - [OpenCode Zen](/providers/opencode) - [Amazon Bedrock](/bedrock) diff --git a/docs/providers/together.md b/docs/providers/together.md new file mode 100644 index 000000000..abf8b4631 --- /dev/null +++ b/docs/providers/together.md @@ -0,0 +1,62 @@ +--- +summary: "Together AI setup (auth + model selection)" +read_when: + - You want to use Together AI with Clawdbot + - You need the API key env var or CLI auth choice +--- +# Together AI + + +The [Together AI](https://together.ai) provides access to leading open-source models including Llama, DeepSeek, Qwen, and more through a unified API. + +- Provider: `together` +- Auth: `TOGETHER_API_KEY` +- API: OpenAI-compatible + +## Quick start + +1) Set the API key (recommended: store it for the Gateway): + +```bash +clawdbot onboard --auth-choice together-api-key +``` + +2) Set a default model: + +```json5 +{ + agents: { + defaults: { + model: { primary: "together/meta-llama/Llama-3.3-70B-Instruct-Turbo" } + } + } +} +``` + +## Non-interactive example + +```bash +clawdbot onboard --non-interactive \ + --mode local \ + --auth-choice together-api-key \ + --together-api-key "$TOGETHER_API_KEY" +``` + +## Environment note + +If the Gateway runs as a daemon (launchd/systemd), make sure `TOGETHER_API_KEY` +is available to that process (for example, in `~/.clawdbot/.env` or via +`env.shellEnv`). + +## Available models + +Together AI provides access to many popular open-source models: + +- **Llama 3.3 70B Instruct Turbo** - Fast, efficient instruction following +- **Llama 4 Scout** - Vision model with image understanding +- **Llama 4 Maverick** - Advanced vision and reasoning +- **DeepSeek V3.1** - Powerful coding and reasoning model +- **DeepSeek R1** - Advanced reasoning model +- **Qwen 2.5 72B** - Multilingual capabilities + +All models support standard chat completions and are OpenAI API compatible. \ No newline at end of file diff --git a/src/agents/model-auth.ts b/src/agents/model-auth.ts index 680d0f53c..da3cd31c7 100644 --- a/src/agents/model-auth.ts +++ b/src/agents/model-auth.ts @@ -285,6 +285,7 @@ export function resolveEnvApiKey(provider: string): EnvApiKeyResult | null { venice: "VENICE_API_KEY", mistral: "MISTRAL_API_KEY", opencode: "OPENCODE_API_KEY", + together: "TOGETHER_API_KEY", }; const envVar = envMap[normalized]; if (!envVar) return null; From ead9ab9b8ca919dbc613f0334543306b7ddcd7d6 Mon Sep 17 00:00:00 2001 From: Riccardo Giorato Date: Sun, 25 Jan 2026 21:35:12 +0100 Subject: [PATCH 3/3] Add Together AI provider with new models, remove together-models.ts --- src/agents/models-config.providers.ts | 114 +++++++++++++++++++++ src/agents/together-models.ts | 121 ----------------------- src/commands/onboard-auth.config-core.ts | 111 ++++++++++++++++++++- src/commands/onboard-auth.ts | 9 +- 4 files changed, 222 insertions(+), 133 deletions(-) delete mode 100644 src/agents/together-models.ts diff --git a/src/agents/models-config.providers.ts b/src/agents/models-config.providers.ts index 996f09dd0..c87bf1217 100644 --- a/src/agents/models-config.providers.ts +++ b/src/agents/models-config.providers.ts @@ -359,6 +359,113 @@ async function buildOllamaProvider(): Promise { }; } +function buildTogetherProvider(): ProviderConfig { + return { + baseUrl: "https://api.together.xyz/v1", + api: "openai-completions", + models: [ + { + id: "meta-llama/Llama-3.3-70B-Instruct-Turbo", + name: "Llama 3.3 70B Instruct Turbo", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.88, + output: 0.88, + cacheRead: 0.88, + cacheWrite: 0.88, + }, + }, + { + id: "meta-llama/Llama-4-Scout-17B-16E-Instruct", + name: "Llama 4 Scout 17B 16E Instruct", + reasoning: false, + input: ["text", "image"], + contextWindow: 10000000, + maxTokens: 32768, + cost: { + input: 0.18, + output: 0.59, + cacheRead: 0.18, + cacheWrite: 0.18, + }, + }, + { + id: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", + name: "Llama 4 Maverick 17B 128E Instruct FP8", + reasoning: false, + input: ["text", "image"], + contextWindow: 20000000, + maxTokens: 32768, + cost: { + input: 0.27, + output: 0.85, + cacheRead: 0.27, + cacheWrite: 0.27, + }, + }, + { + id: "deepseek-ai/DeepSeek-V3.1", + name: "DeepSeek V3.1", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.6, + output: 1.25, + cacheRead: 0.6, + cacheWrite: 0.6, + }, + }, + { + id: "deepseek-ai/DeepSeek-R1", + name: "DeepSeek R1", + reasoning: true, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 3.0, + output: 7.0, + cacheRead: 3.0, + cacheWrite: 3.0, + }, + }, + { + id: "Qwen/Qwen2.5-72B-Instruct-Turbo", + name: "Qwen 2.5 72B Instruct Turbo", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.35, + output: 0.8, + cacheRead: 0.35, + cacheWrite: 0.35, + }, + }, + { + id: "mistralai/Mixtral-8x7B-Instruct-v0.1", + name: "Mixtral 8x7B Instruct v0.1", + reasoning: false, + input: ["text"], + contextWindow: 32768, + maxTokens: 8192, + cost: { + input: 0.6, + output: 0.6, + cacheRead: 0.6, + cacheWrite: 0.6, + }, + }, + ], + }; +} + export async function resolveImplicitProviders(params: { agentDir: string; }): Promise { @@ -418,6 +525,13 @@ export async function resolveImplicitProviders(params: { providers.ollama = { ...(await buildOllamaProvider()), apiKey: ollamaKey }; } + const togetherKey = + resolveEnvApiKeyVarName("together") ?? + resolveApiKeyFromProfiles({ provider: "together", store: authStore }); + if (togetherKey) { + providers.together = { ...buildTogetherProvider(), apiKey: togetherKey }; + } + return providers; } diff --git a/src/agents/together-models.ts b/src/agents/together-models.ts deleted file mode 100644 index a16e96837..000000000 --- a/src/agents/together-models.ts +++ /dev/null @@ -1,121 +0,0 @@ -import type { ModelDefinitionConfig } from "../config/types.js"; - -export const TOGETHER_BASE_URL = "https://api.together.xyz/v1"; -export const TOGETHER_DEFAULT_MODEL_ID = "meta-llama/Llama-3.3-70B-Instruct-Turbo"; -export const TOGETHER_DEFAULT_MODEL_REF = `together/${TOGETHER_DEFAULT_MODEL_ID}`; - -export const TOGETHER_MODEL_CATALOG = [ - { - id: "meta-llama/Llama-3.3-70B-Instruct-Turbo", - name: "Llama 3.3 70B Instruct Turbo", - reasoning: false, - input: ["text"], - contextWindow: 131072, - maxTokens: 8192, - cost: { - input: 0.88, - output: 0.88, - cacheRead: 0.88, - cacheWrite: 0.88, - }, - }, - { - id: "meta-llama/Llama-4-Scout-17B-16E-Instruct", - name: "Llama 4 Scout 17B 16E Instruct", - reasoning: false, - input: ["text", "image"], - contextWindow: 10000000, - maxTokens: 32768, - cost: { - input: 0.18, - output: 0.59, - cacheRead: 0.18, - cacheWrite: 0.18, - }, - }, - { - id: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", - name: "Llama 4 Maverick 17B 128E Instruct FP8", - reasoning: false, - input: ["text", "image"], - contextWindow: 20000000, - maxTokens: 32768, - cost: { - input: 0.27, - output: 0.85, - cacheRead: 0.27, - cacheWrite: 0.27, - }, - }, - { - id: "deepseek-ai/DeepSeek-V3.1", - name: "DeepSeek V3.1", - reasoning: false, - input: ["text"], - contextWindow: 131072, - maxTokens: 8192, - cost: { - input: 0.6, - output: 1.25, - cacheRead: 0.6, - cacheWrite: 0.6, - }, - }, - { - id: "deepseek-ai/DeepSeek-R1", - name: "DeepSeek R1", - reasoning: true, - input: ["text"], - contextWindow: 131072, - maxTokens: 8192, - cost: { - input: 3.0, - output: 7.0, - cacheRead: 3.0, - cacheWrite: 3.0, - }, - }, - { - id: "Qwen/Qwen2.5-72B-Instruct-Turbo", - name: "Qwen 2.5 72B Instruct Turbo", - reasoning: false, - input: ["text"], - contextWindow: 131072, - maxTokens: 8192, - cost: { - input: 0.35, - output: 0.8, - cacheRead: 0.35, - cacheWrite: 0.35, - }, - }, - { - id: "mistralai/Mixtral-8x7B-Instruct-v0.1", - name: "Mixtral 8x7B Instruct v0.1", - reasoning: false, - input: ["text"], - contextWindow: 32768, - maxTokens: 8192, - cost: { - input: 0.6, - output: 0.6, - cacheRead: 0.6, - cacheWrite: 0.6, - }, - }, -] as const; - -export function buildTogetherModelDefinition( - model: (typeof TOGETHER_MODEL_CATALOG)[number], -): ModelDefinitionConfig { - return { - id: model.id, - name: model.name, - api: "openai-completions", - reasoning: model.reasoning, - input: [...model.input], - cost: model.cost, - contextWindow: model.contextWindow, - maxTokens: model.maxTokens, - }; -} diff --git a/src/commands/onboard-auth.config-core.ts b/src/commands/onboard-auth.config-core.ts index 17ad16a2e..4c621217d 100644 --- a/src/commands/onboard-auth.config-core.ts +++ b/src/commands/onboard-auth.config-core.ts @@ -4,11 +4,111 @@ import { SYNTHETIC_DEFAULT_MODEL_REF, SYNTHETIC_MODEL_CATALOG, } from "../agents/synthetic-models.js"; -import { - buildTogetherModelDefinition, - TOGETHER_BASE_URL, - TOGETHER_MODEL_CATALOG, -} from "../agents/together-models.js"; + +// Together AI constants and models - inline to avoid separate models file +const TOGETHER_BASE_URL = "https://api.together.xyz/v1"; +const TOGETHER_MODEL_CATALOG = [ + { + id: "meta-llama/Llama-3.3-70B-Instruct-Turbo", + name: "Llama 3.3 70B Instruct Turbo", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.88, + output: 0.88, + cacheRead: 0.88, + cacheWrite: 0.88, + }, + }, + { + id: "meta-llama/Llama-4-Scout-17B-16E-Instruct", + name: "Llama 4 Scout 17B 16E Instruct", + reasoning: false, + input: ["text", "image"], + contextWindow: 10000000, + maxTokens: 32768, + cost: { + input: 0.18, + output: 0.59, + cacheRead: 0.18, + cacheWrite: 0.18, + }, + }, + { + id: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", + name: "Llama 4 Maverick 17B 128E Instruct FP8", + reasoning: false, + input: ["text", "image"], + contextWindow: 20000000, + maxTokens: 32768, + cost: { + input: 0.27, + output: 0.85, + cacheRead: 0.27, + cacheWrite: 0.27, + }, + }, + { + id: "deepseek-ai/DeepSeek-V3.1", + name: "DeepSeek V3.1", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.6, + output: 1.25, + cacheRead: 0.6, + cacheWrite: 0.6, + }, + }, + { + id: "deepseek-ai/DeepSeek-R1", + name: "DeepSeek R1", + reasoning: true, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 3.0, + output: 7.0, + cacheRead: 3.0, + cacheWrite: 3.0, + }, + }, + { + id: "Qwen/Qwen2.5-72B-Instruct-Turbo", + name: "Qwen 2.5 72B Instruct Turbo", + reasoning: false, + input: ["text"], + contextWindow: 131072, + maxTokens: 8192, + cost: { + input: 0.35, + output: 0.8, + cacheRead: 0.35, + cacheWrite: 0.35, + }, + }, +]; + +function buildTogetherModelDefinition( + model: (typeof TOGETHER_MODEL_CATALOG)[number], +): ModelDefinitionConfig { + return { + id: model.id, + name: model.name, + api: "openai-completions", + reasoning: model.reasoning, + input: model.input as ("text" | "image")[], + cost: model.cost, + contextWindow: model.contextWindow, + maxTokens: model.maxTokens, + }; +} + import { buildVeniceModelDefinition, VENICE_BASE_URL, @@ -16,6 +116,7 @@ import { VENICE_MODEL_CATALOG, } from "../agents/venice-models.js"; import type { ClawdbotConfig } from "../config/config.js"; +import type { ModelDefinitionConfig } from "../config/types.models.js"; import { OPENROUTER_DEFAULT_MODEL_REF, TOGETHER_DEFAULT_MODEL_REF, diff --git a/src/commands/onboard-auth.ts b/src/commands/onboard-auth.ts index 555093765..b970457bf 100644 --- a/src/commands/onboard-auth.ts +++ b/src/commands/onboard-auth.ts @@ -68,10 +68,5 @@ export { MOONSHOT_DEFAULT_MODEL_ID, MOONSHOT_DEFAULT_MODEL_REF, } from "./onboard-auth.models.js"; -export { - buildTogetherModelDefinition, - TOGETHER_BASE_URL, - TOGETHER_DEFAULT_MODEL_ID, - TOGETHER_DEFAULT_MODEL_REF, - TOGETHER_MODEL_CATALOG, -} from "../agents/together-models.js"; +// Together AI constants are now defined inline in onboard-auth.config-core.ts +export { TOGETHER_DEFAULT_MODEL_REF } from "./onboard-auth.credentials.js";