1
2
Set HELICONE_API_KEY as an environment variable
3
Modify the API base and add the `Helicone-Auth` header
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use LangChain to integrate Anthropic with Helicone to log your Anthropic LLM usage.
Set HELICONE_API_KEY as an environment variable
export HELICONE_API_KEY=<your API key>
Modify the API base and add the `Helicone-Auth` header
const llm = new ChatAnthropic({
modelName: "claude-2",
anthropicApiKey: "ANTHROPIC_API_KEY",
clientOptions: {
baseURL: "https://anthropic.helicone.ai",
defaultHeaders: {
"Helicone-Auth": `Bearer ${HELICONE_API_KEY}`,
},
},
});
anthropic = ChatAnthropic(
temperature=0.9,
model="claude-2",
anthropic_api_url="https://anthropic.helicone.ai",
anthropic_api_key="ANTHROPIC_API_KEY",
model_kwargs={
"extra_headers":{
"Helicone-Auth": f"Bearer {HELICONE_API_KEY}"
}
}
)
import os
from llama_index.multi_modal_llms.anthropic import AnthropicMultiModal
from llama_index.core.multi_modal_llms.generic_utils import load_image_urls
# Initialize the AnthropicMultiModal class with your Anthropic API key
anthropic_mm_llm = AnthropicMultiModal(
max_tokens=300,
default_headers={
"Helicone-Auth": f"Bearer {os.environ['HELICONE_API_KEY']}",
},
api_key="<your Anthropic API key>",
api_base="https://anthropic.helicone.ai",
)
# Provide image URLs
image_urls = ["https://example.com/image1.png"]
# Load image URLs into documents
image_url_documents = load_image_urls(image_urls)
# Generate a response based on the images
response = anthropic_mm_llm.complete(
prompt="Describe the images as alternative text",
image_documents=image_url_documents,
)
print(response)
Was this page helpful?