Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,8 @@
"form-data": ">=4.0.4",
"bluebird": ">=3.7.2"
}
},
"dependencies": {
"@streamparser/json": "^0.0.22"
}
}
2 changes: 2 additions & 0 deletions packages/types/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const modelInfoSchema = z.object({
contextWindow: z.number(),
supportsImages: z.boolean().optional(),
supportsPromptCache: z.boolean(),
// Capability flag to indicate whether the model supports native tool calling
supportsNativeToolCalling: z.boolean().optional(),
// Capability flag to indicate whether the model supports an output verbosity parameter
supportsVerbosity: z.boolean().optional(),
supportsReasoningBudget: z.boolean().optional(),
Expand Down
11 changes: 11 additions & 0 deletions packages/types/src/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const anthropicModels = {
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 3.0, // $3 per million input tokens (≤200K context)
outputPrice: 15.0, // $15 per million output tokens (≤200K context)
cacheWritesPrice: 3.75, // $3.75 per million tokens
Expand All @@ -32,6 +33,7 @@ export const anthropicModels = {
contextWindow: 200_000, // Default 200K, extendable to 1M with beta flag 'context-1m-2025-08-07'
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 3.0, // $3 per million input tokens (≤200K context)
outputPrice: 15.0, // $15 per million output tokens (≤200K context)
cacheWritesPrice: 3.75, // $3.75 per million tokens
Expand All @@ -53,6 +55,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 15.0, // $15 per million input tokens
outputPrice: 75.0, // $75 per million output tokens
cacheWritesPrice: 18.75, // $18.75 per million tokens
Expand All @@ -64,6 +67,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 15.0, // $15 per million input tokens
outputPrice: 75.0, // $75 per million output tokens
cacheWritesPrice: 18.75, // $18.75 per million tokens
Expand All @@ -75,6 +79,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 3.0, // $3 per million input tokens
outputPrice: 15.0, // $15 per million output tokens
cacheWritesPrice: 3.75, // $3.75 per million tokens
Expand All @@ -87,6 +92,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 3.0, // $3 per million input tokens
outputPrice: 15.0, // $15 per million output tokens
cacheWritesPrice: 3.75, // $3.75 per million tokens
Expand All @@ -97,6 +103,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 3.0, // $3 per million input tokens
outputPrice: 15.0, // $15 per million output tokens
cacheWritesPrice: 3.75, // $3.75 per million tokens
Expand All @@ -107,6 +114,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: false,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.0,
outputPrice: 5.0,
cacheWritesPrice: 1.25,
Expand All @@ -117,6 +125,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 15.0,
outputPrice: 75.0,
cacheWritesPrice: 18.75,
Expand All @@ -127,6 +136,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 0.25,
outputPrice: 1.25,
cacheWritesPrice: 0.3,
Expand All @@ -137,6 +147,7 @@ export const anthropicModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.0,
outputPrice: 5.0,
cacheWritesPrice: 1.25,
Expand Down
23 changes: 23 additions & 0 deletions packages/types/src/providers/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const openAiNativeModels = {
contextWindow: 400000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
supportsReasoningEffort: false,
inputPrice: 1.25,
outputPrice: 10.0,
Expand All @@ -23,6 +24,7 @@ export const openAiNativeModels = {
contextWindow: 400000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
supportsReasoningEffort: true,
reasoningEffort: "medium",
inputPrice: 1.25,
Expand All @@ -42,6 +44,7 @@ export const openAiNativeModels = {
contextWindow: 400000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
supportsReasoningEffort: true,
reasoningEffort: "medium",
inputPrice: 0.25,
Expand All @@ -60,6 +63,7 @@ export const openAiNativeModels = {
contextWindow: 400000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
supportsReasoningEffort: true,
reasoningEffort: "medium",
inputPrice: 0.05,
Expand All @@ -75,6 +79,7 @@ export const openAiNativeModels = {
contextWindow: 400000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
supportsReasoningEffort: true,
reasoningEffort: "medium",
inputPrice: 1.25,
Expand All @@ -89,6 +94,7 @@ export const openAiNativeModels = {
contextWindow: 1_047_576,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 2,
outputPrice: 8,
cacheReadsPrice: 0.5,
Expand All @@ -102,6 +108,7 @@ export const openAiNativeModels = {
contextWindow: 1_047_576,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 0.4,
outputPrice: 1.6,
cacheReadsPrice: 0.1,
Expand All @@ -115,6 +122,7 @@ export const openAiNativeModels = {
contextWindow: 1_047_576,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 0.1,
outputPrice: 0.4,
cacheReadsPrice: 0.025,
Expand All @@ -128,6 +136,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 2.0,
outputPrice: 8.0,
cacheReadsPrice: 0.5,
Expand All @@ -144,6 +153,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 2.0,
outputPrice: 8.0,
cacheReadsPrice: 0.5,
Expand All @@ -155,6 +165,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 2.0,
outputPrice: 8.0,
cacheReadsPrice: 0.5,
Expand All @@ -166,6 +177,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.1,
outputPrice: 4.4,
cacheReadsPrice: 0.275,
Expand All @@ -182,6 +194,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.1,
outputPrice: 4.4,
cacheReadsPrice: 0.275,
Expand All @@ -193,6 +206,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.1,
outputPrice: 4.4,
cacheReadsPrice: 0.275,
Expand All @@ -204,6 +218,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: false,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.1,
outputPrice: 4.4,
cacheReadsPrice: 0.55,
Expand All @@ -216,6 +231,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: false,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.1,
outputPrice: 4.4,
cacheReadsPrice: 0.55,
Expand All @@ -227,6 +243,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: false,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.1,
outputPrice: 4.4,
cacheReadsPrice: 0.55,
Expand All @@ -238,6 +255,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 15,
outputPrice: 60,
cacheReadsPrice: 7.5,
Expand All @@ -248,6 +266,7 @@ export const openAiNativeModels = {
contextWindow: 128_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 15,
outputPrice: 60,
cacheReadsPrice: 7.5,
Expand All @@ -258,6 +277,7 @@ export const openAiNativeModels = {
contextWindow: 128_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 1.1,
outputPrice: 4.4,
cacheReadsPrice: 0.55,
Expand All @@ -268,6 +288,7 @@ export const openAiNativeModels = {
contextWindow: 128_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 2.5,
outputPrice: 10,
cacheReadsPrice: 1.25,
Expand All @@ -281,6 +302,7 @@ export const openAiNativeModels = {
contextWindow: 128_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeToolCalling: true,
inputPrice: 0.15,
outputPrice: 0.6,
cacheReadsPrice: 0.075,
Expand All @@ -294,6 +316,7 @@ export const openAiNativeModels = {
contextWindow: 200_000,
supportsImages: false,
supportsPromptCache: false,
supportsNativeToolCalling: true,
inputPrice: 1.5,
outputPrice: 6,
cacheReadsPrice: 0,
Expand Down
14 changes: 13 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
import type { ProviderSettings, ModelInfo } from "@roo-code/types"

import { ApiStream } from "./transform/stream"
import type { ToolSpec } from "./transform/tool-converters"

import {
GlamaHandler,
Expand Down Expand Up @@ -73,6 +74,7 @@ export interface ApiHandler {
systemPrompt: string,
messages: Anthropic.Messages.MessageParam[],
metadata?: ApiHandlerCreateMessageMetadata,
tools?: ToolSpec[],
): ApiStream

getModel(): { id: string; info: ModelInfo }
Expand All @@ -86,6 +88,15 @@ export interface ApiHandler {
* @returns A promise resolving to the token count
*/
countTokens(content: Array<Anthropic.Messages.ContentBlockParam>): Promise<number>

/**
* Returns whether this provider supports native tool calling
* Providers that support native tools can receive tool specifications and
* handle them in their native format instead of using XML-based tools
*
* @returns true if the provider supports native tool calling, false otherwise
*/
supportsNativeTools(): boolean
}

export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
Expand Down
Loading
Loading