From dce96478c7d562a19af747d356e3c9bf0ff01d29 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 5 Apr 2024 21:48:38 -0700 Subject: [PATCH] docs(vertex.md): add claude 3 on vertex ai to docs --- docs/my-website/docs/providers/vertex.md | 80 +++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/docs/my-website/docs/providers/vertex.md b/docs/my-website/docs/providers/vertex.md index 90313c9fa7c..b5d69084d79 100644 --- a/docs/my-website/docs/providers/vertex.md +++ b/docs/my-website/docs/providers/vertex.md @@ -2,7 +2,7 @@ import Image from '@theme/IdealImage'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# VertexAI - Google [Gemini, Model Garden] +# VertexAI [Anthropic, Gemini, Model Garden] Open In Colab @@ -250,6 +250,84 @@ os.environ["VERTEXAI_LOCATION"] = "us-central1 # Your Location # set directly on module litellm.vertex_location = "us-central1 # Your Location ``` +## Anthropic +| Model Name | Function Call | +|------------------|--------------------------------------| +| claude-3-sonnet@20240229 | `completion('vertex_ai/claude-3-sonnet@20240229', messages)` | +| claude-3-haiku@20240307 | `completion('vertex_ai/claude-3-haiku@20240307', messages)` | + +### Usage + + + + +```python +from litellm import completion +import os + +os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "" + +model = "claude-3-sonnet@20240229" + +vertex_ai_project = "your-vertex-project" # can also set this as os.environ["VERTEXAI_PROJECT"] +vertex_ai_location = "your-vertex-location" # can also set this as os.environ["VERTEXAI_LOCATION"] + +response = completion( + model="vertex_ai/" + model, + messages=[{"role": "user", "content": "hi"}], + temperature=0.7, + vertex_ai_project=vertex_ai_project, + vertex_ai_location=vertex_ai_location, +) +print("\nModel Response", response) +``` + + + +**1. Add to config** + +```yaml +model_list: + - model_name: anthropic-vertex + litellm_params: + model: vertex_ai/claude-3-sonnet@20240229 + vertex_ai_project: "my-test-project" + vertex_ai_location: "us-east-1" + - model_name: anthropic-vertex + litellm_params: + model: vertex_ai/claude-3-sonnet@20240229 + vertex_ai_project: "my-test-project" + vertex_ai_location: "us-west-1" +``` + +**2. Start proxy** + +```bash +litellm --config /path/to/config.yaml + +# RUNNING at http://0.0.0.0:4000 +``` + +**3. Test it!** + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ + --header 'Authorization: Bearer sk-1234' \ + --header 'Content-Type: application/json' \ + --data '{ + "model": "anthropic-vertex", # 👈 the 'model_name' in config + "messages": [ + { + "role": "user", + "content": "what llm are you" + } + ], + }' +``` + + + + ## Model Garden | Model Name | Function Call | |------------------|--------------------------------------|