AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(backend): add support for v0 by Vercel models and credentials (#10641)
Nicholas Tindle6bb6a081a24d
diff --git a/autogpt_platform/backend/.env.default b/autogpt_platform/backend/.env.defaultindex 30c7f4eb8f..a25f0717a8 100644--- a/autogpt_platform/backend/.env.default+++ b/autogpt_platform/backend/.env.default@@ -55,6 +55,7 @@ ANTHROPIC_API_KEY=GROQ_API_KEY=LLAMA_API_KEY=AIML_API_KEY=+V0_API_KEY=OPEN_ROUTER_API_KEY=NVIDIA_API_KEY=diff --git a/autogpt_platform/backend/backend/blocks/llm.py b/autogpt_platform/backend/backend/blocks/llm.pyindex 50f5b4f092..b20df4052e 100644--- a/autogpt_platform/backend/backend/blocks/llm.py+++ b/autogpt_platform/backend/backend/blocks/llm.py@@ -37,6 +37,7 @@ LLMProviderName = Literal[ProviderName.OPENAI,ProviderName.OPEN_ROUTER,ProviderName.LLAMA_API,+ ProviderName.V0,]AICredentials = CredentialsMetaInput[LLMProviderName, Literal["api_key"]]@@ -155,6 +156,10 @@ class LlmModel(str, Enum, metaclass=LlmModelMeta):LLAMA_API_LLAMA4_MAVERICK = "Llama-4-Maverick-17B-128E-Instruct-FP8"LLAMA_API_LLAMA3_3_8B = "Llama-3.3-8B-Instruct"LLAMA_API_LLAMA3_3_70B = "Llama-3.3-70B-Instruct"+ # v0 by Vercel models+ V0_1_5_MD = "v0-1.5-md"+ V0_1_5_LG = "v0-1.5-lg"+ V0_1_0_MD = "v0-1.0-md"@propertydef metadata(self) -> ModelMetadata:@@ -280,6 +285,10 @@ MODEL_METADATA = {LlmModel.LLAMA_API_LLAMA4_MAVERICK: ModelMetadata("llama_api", 128000, 4028),LlmModel.LLAMA_API_LLAMA3_3_8B: ModelMetadata("llama_api", 128000, 4028),LlmModel.LLAMA_API_LLAMA3_3_70B: ModelMetadata("llama_api", 128000, 4028),+ # v0 by Vercel models+ LlmModel.V0_1_5_MD: ModelMetadata("v0", 128000, 64000),+ LlmModel.V0_1_5_LG: ModelMetadata("v0", 512000, 64000),+ LlmModel.V0_1_0_MD: ModelMetadata("v0", 128000, 64000),}for model in LlmModel:@@ -700,6 +709,42 @@ async def llm_call(),reasoning=None,)+ elif provider == "v0":+ tools_param = tools if tools else openai.NOT_GIVEN+ client = openai.AsyncOpenAI(+ base_url="https://api.v0.dev/v1",+ api_key=credentials.api_key.get_secret_value(),+ )++ response_format = None+ if json_format:+ response_format = {"type": "json_object"}++ parallel_tool_calls_param = get_parallel_tool_calls_param(+ llm_model, parallel_tool_calls+ )++ response = await client.chat.completions.create(+ model=llm_model.value,+ messages=prompt, # type: ignore+ response_format=response_format, # type: ignore+ max_tokens=max_tokens,+ tools=tools_param, # type: ignore+ parallel_tool_calls=parallel_tool_calls_param,+ )++ tool_calls = extract_openai_tool_calls(response)+ reasoning = extract_openai_reasoning(response)++ return LLMResponse(+ raw_response=response.choices[0].message,+ prompt=prompt,+ response=response.choices[0].message.content or "",+ tool_calls=tool_calls,+ prompt_tokens=response.usage.prompt_tokens if response.usage else 0,+ completion_tokens=response.usage.completion_tokens if response.usage else 0,+ reasoning=reasoning,+ )else:raise ValueError(f"Unsupported LLM provider: {provider}")diff --git a/autogpt_platform/backend/backend/data/block_cost_config.py b/autogpt_platform/backend/backend/data/block_cost_config.pyindex dbc27a2795..1331d5eba8 100644--- a/autogpt_platform/backend/backend/data/block_cost_config.py+++ b/autogpt_platform/backend/backend/data/block_cost_config.py@@ -46,6 +46,7 @@ from backend.integrations.credentials_store import (replicate_credentials,revid_credentials,unreal_credentials,+ v0_credentials,)# =============== Configure the cost for each LLM Model call =============== #@@ -122,6 +123,10 @@ MODEL_COST: dict[LlmModel, int] = {LlmModel.GEMINI_2_5_FLASH_LITE_PREVIEW: 1,LlmModel.GEMINI_2_0_FLASH_LITE: 1,LlmModel.DEEPSEEK_R1_0528: 1,+ # v0 by Vercel models+ LlmModel.V0_1_5_MD: 1,+ LlmModel.V0_1_5_LG: 2,+ LlmModel.V0_1_0_MD: 1,}for model in LlmModel:@@ -211,6 +216,23 @@ LLM_COST = (for model, cost in MODEL_COST.items()if MODEL_METADATA[model].provider == "llama_api"]+ # v0 by Vercel Models+ + [+ BlockCost(+ cost_type=BlockCostType.RUN,+ cost_filter={+ "model": model,+ "credentials": {+ "id": v0_credentials.id,+ "provider": v0_credentials.provider,+ "type": v0_credentials.type,+ },+ },+ cost_amount=cost,+ )+ for model, cost in MODEL_COST.items()+ if MODEL_METADATA[model].provider == "v0"+ ]# AI/ML Api Models+ [BlockCost(diff --git a/autogpt_platform/backend/backend/integrations/credentials_store.py b/autogpt_platform/backend/backend/integrations/credentials_store.pyindex fea6937a04..75ae346d5d 100644--- a/autogpt_platform/backend/backend/integrations/credentials_store.py+++ b/autogpt_platform/backend/backend/integrations/credentials_store.py@@ -199,6 +199,14 @@ llama_api_credentials = APIKeyCredentials(expires_at=None,)+v0_credentials = APIKeyCredentials(+ id="c4e6d1a0-3b5f-4789-a8e2-9b123456789f",+ provider="v0",+ api_key=SecretStr(settings.secrets.v0_api_key),+ title="Use Credits for v0 by Vercel",+ expires_at=None,+)+DEFAULT_CREDENTIALS = [ollama_credentials,revid_credentials,@@ -223,6 +231,8 @@ DEFAULT_CREDENTIALS = [smartlead_credentials,zerobounce_credentials,google_maps_credentials,+ llama_api_credentials,+ v0_credentials,]diff --git a/autogpt_platform/backend/backend/integrations/providers.py b/autogpt_platform/backend/backend/integrations/providers.pyindex 587da16a8c..3564ad32a8 100644--- a/autogpt_platform/backend/backend/integrations/providers.py+++ b/autogpt_platform/backend/backend/integrations/providers.py@@ -48,6 +48,7 @@ class ProviderName(str, Enum):TWITTER = "twitter"TODOIST = "todoist"UNREAL_SPEECH = "unreal_speech"+ V0 = "v0"ZEROBOUNCE = "zerobounce"@classmethoddiff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.pyindex d5e1c1abaf..9baa8de099 100644--- a/autogpt_platform/backend/backend/util/settings.py+++ b/autogpt_platform/backend/backend/util/settings.py@@ -472,6 +472,7 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings):groq_api_key: str = Field(default="", description="Groq API key")open_router_api_key: str = Field(default="", description="Open Router API Key")llama_api_key: str = Field(default="", description="Llama API Key")+ v0_api_key: str = Field(default="", description="v0 by Vercel API key")reddit_client_id: str = Field(default="", description="Reddit client ID")reddit_client_secret: str = Field(default="", description="Reddit client secret")