powered by
Generate text completions using Anthropic's API
create_completion_anthropic( prompt = list(list(role = "user", content = "Hello")), system = NULL, model = "claude-3-haiku-20240307", max_tokens = 1028, key = Sys.getenv("ANTHROPIC_API_KEY") )
A list with the generated completions and other information returned by the API.
The prompt for generating completions
A system messages to instruct the model. Defaults to NULL.
The model to use for generating text. By default, the function will try to use "claude-2.1".
The maximum number of tokens to generate. Defaults to 256.
The API key for accessing Anthropic's API. By default, the function will try to use the ANTHROPIC_API_KEY environment variable.
ANTHROPIC_API_KEY
if (FALSE) { create_completion_anthropic( prompt = "\n\nHuman: Hello, world!\n\nAssistant:", model = "claude-3-haiku-20240307", max_tokens = 1028 ) }
Run the code above in your browser using DataLab