artopenai provides R bindings for OpenAI’s Responses API with specialized functions for artwork analysis in the Artalytics platform.
Environment Variables
artopenai is configured entirely through environment variables. Set these before loading the package. This section is the source of truth for all ART_OPENAI_* configuration.
Required
-
ART_OPENAI_KEYYour OpenAI API key. Get one at https://platform.openai.com/api-keys Example:Sys.setenv(ART_OPENAI_KEY = "sk-...")
Optional (with defaults)
-
ART_OPENAI_MODEL(default:gpt-5.1) Model to use for requests. Common models:-
gpt-5.1: Latest reasoning model (default) -
gpt-5.1-mini: Faster, lower cost variant
-
ART_OPENAI_BASE_URL(default:https://api.openai.com/v1) OpenAI API base URL. Change only if using a proxy or custom endpoint.ART_OPENAI_MAX_OUTPUT_TOKENS(default:4096) Defaultmax_output_tokenscap sent to the OpenAI Responses API. Increase this if structured outputs (JSON schema) are being truncated (you may seestatus="incomplete"withincomplete_details.reason="max_output_tokens"). Must be an integer >= 16.
Setting Environment Variables
In R session:
Sys.setenv(
ART_OPENAI_KEY = "sk-your-api-key",
ART_OPENAI_MODEL = "gpt-5.1-mini",
ART_OPENAI_MAX_OUTPUT_TOKENS = "8192"
)In .Renviron file (persistent across sessions):
ART_OPENAI_KEY=sk-your-api-key
ART_OPENAI_MODEL=gpt-5.1-mini
ART_OPENAI_MAX_OUTPUT_TOKENS=8192
Note: All function documentation and examples assume these environment variables are properly configured. See individual function help pages for parameter-level overrides (e.g., ml parameter).
Quick Example
library(artopenai)
# Interactive chat (NEW in 0.11.0)
chat <- openai_chat(sys_prompt = "You are an art expert.")
chat$chat("What is Baroque art?")
chat$chat("How does it differ from Renaissance?")
# Single-turn with tools
openai_with_tools("What are the key characteristics of Baroque art?")Package Hierarchy
appPlatform / mod* packages (consumers)
|
artopenai (this package)
|
artcore (infrastructure layer)
artopenai is a sibling package to artgemini, providing the same artwork analysis functions using OpenAI’s API instead of Google Gemini.
Documentation
- Get Started - Package overview
- Quickstart - Hands-on tutorial
- Advanced Workflow - Complex use cases
- Function Reference - Complete API documentation
Development
For AI agent instructions and coding standards, see AGENTS.md.
Testing
Tests are recorded/replayed with {httptest2}; fixtures live in tests/testthat/fixtures/ so the suite runs offline after initial capture. Run devtools::test() to exercise the mocked flows.
Proprietary - Do Not Distribute
