Anthropic
The UC AI Anthropic package integrates Anthropicâs Claude models into your Oracle database applications.
Features
Section titled âFeaturesâ- Support for the current Claude models (Fable, Opus, Sonnet, Haiku)
- Full function calling (tools) support
- Structured output (JSON schema-based responses)
- Reasoning capabilities with Extended Thinking
- Multi-modal support (text, images, PDFs)
- Streaming responses
Prerequisites
Section titled âPrerequisitesâ- Anthropic API key
- Oracle database with internet access to Anthropicâs API endpoints (see Network Setup (ACL & Wallet))
- UC AI package installed
- Set up API key (guide)
You can get an API key by signing up at Anthropic Console.
Creating a Web Credential
Section titled âCreating a Web CredentialâTo use your Anthropic key with APEX Web Credentials, create a new web credential in your APEX workspace (Workspace Utilities â Web Credentials) with the following configuration:
- Authentication Type: HTTP Header
- Credential Name:
x-api-key - Credential Secret:
<your_api_key>
Also set Valid for URLs to the Anthropic API (https://api.anthropic.com/) to limit the scope of the credential.
To use the web credential in your PL/SQL code, set the package variable uc_ai_anthropic.g_apex_web_credential to the static ID of your web credential before calling any UC AI functions:
uc_ai_anthropic.g_apex_web_credential := 'ANTHROPIC';Anthropic builds a range of models called Claude. The Haiku models are optimized for speed and cost. The Sonnet models balance performance and speed. The Opus and Fable models are the most capable, and also the most expensive. See this model reference for details on each model. Refer to Artifical Analysis for a comparison of intelligence, speed, and price.
The UC AI Anthropic package provides constants for these Claude models:
Current Models
Section titled âCurrent Modelsâuc_ai_anthropic.c_model_claude_5_5_opus- Claude Opus 5.5, for long-running agentic coding and knowledge workuc_ai_anthropic.c_model_claude_5_5_sonnet- Claude Sonnet 5.5, the best combination of speed and intelligenceuc_ai_anthropic.c_model_claude_5_1_fable- Claude Fable 5.1, for demanding reasoning and long-running agentsuc_ai_anthropic.c_model_claude_4_5_haiku- Claude Haiku 4.5, the fastest model
This list shows the newest model of each family. The package keeps the constants of older models for code that still references them.
Retired Models
Section titled âRetired ModelsâAnthropic retired the Claude 3 models, the Claude 4.0 models, and Claude Opus 4.1. The package keeps their constants for code that still references them, but requests with these models fail. See the Anthropic deprecation list for the dates.
Usage Examples
Section titled âUsage ExamplesâBasic Text Generation
Section titled âBasic Text Generationâdeclare l_result json_object_t;begin l_result := uc_ai.generate_text( p_user_prompt => 'What is Oracle APEX?', p_provider => uc_ai.c_provider_anthropic, p_model => uc_ai_anthropic.c_model_claude_5_sonnet );
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));end;/With System Prompt
Section titled âWith System Promptâdeclare l_result json_object_t;begin l_result := uc_ai.generate_text( p_user_prompt => 'I have tomatoes, salad, potatoes, olives, and cheese. What can I cook with that?', p_system_prompt => 'You are an assistant helping users to get recipes. Please just list 3 possible dish names without instructions.', p_provider => uc_ai.c_provider_anthropic, p_model => uc_ai_anthropic.c_model_claude_4_5_haiku );
dbms_output.put_line('Recipe suggestions: ' || l_result.get_string('final_message'));end;/Max tokens
Section titled âMax tokensâAnthropic requires an upper limit of generated tokens to be sent with API requests. UC AI defaults this setting to 8192. If you want to generate longer answers or reasoning sequences you have to increase this value:
uc_ai_anthropic.g_max_tokens := 32768;All Claude models support tools/function calling. You can define tools in your application and Claude will call them as needed.
See the tools guide for details on how to set up and use tools.
Structured Output
Section titled âStructured OutputâClaude models support structured output with JSON schemas. UC AI automatically converts your schema to the format required by Anthropicâs API. See Anthropicâs structured output documentation for model support and best practices.
declare l_result json_object_t; l_schema json_object_t; l_structured_output json_object_t;begin l_schema := json_object_t(q'#{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "title": "Simple AI Response", "properties": { "response": { "type": "string", "description": "The generated response text" }, "confidence": { "type": "number", "description": "Confidence score between 0 and 1" } }, "required": ["response", "confidence"] }#');
l_result := uc_ai.generate_text( p_user_prompt => 'What is the capital of France? Please respond with confidence.', p_system_prompt => 'You are a helpful assistant that provides accurate information.', p_provider => uc_ai.c_provider_anthropic, p_model => uc_ai_anthropic.c_model_claude_4_5_haiku, p_response_json_schema => l_schema );
l_structured_output := json_object_t(l_result.get_clob('final_message'));
dbms_output.put_line('Response: ' || l_structured_output.get_string('response')); dbms_output.put_line('Confidence: ' || l_structured_output.get_number('confidence')); -- Response: The capital of France is Paris. -- Confidence: 1end;/See the structured output guide for more details.
Multi-modal Analysis
Section titled âMulti-modal AnalysisâClaude models have vision capabilities for Image and PDF Analysis.
Refer to the file analysis guide for examples on how to analyze images and PDFs.
Reasoning / Extended Thinking
Section titled âReasoning / Extended ThinkingâClaude models support reasoning. When you enable it, Claude reasons internally before it gives its final answer. Refer to Anthropics Extended Thinking guide for model support and best practices.
Make sure to set the uc_ai.g_enable_reasoning variable to true. Additionally you can configure the reasoning budget to limit the number of tokens used for reasoning:
declare l_result json_object_t;begin uc_ai.g_enable_reasoning := true; uc_ai_anthropic.g_reasoning_budget_tokens := 2048; -- Optional: set reasoning token budget
l_result := uc_ai.generate_text( p_user_prompt => 'Why have relational databases been so successful?', p_provider => uc_ai.c_provider_anthropic, p_model => uc_ai_anthropic.c_model_claude_4_5_sonnet );
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));end;/The response messages array includes the reasoning as content with type reasoning. Use it to inspect Claudeâs thought process.