scio provides AI-generated summaries of R objects (data frames, plots, text) via the OpenRouter API. Initially conceived to help automate insights from iterative data analysis in notebooks.
You can install the development version of scio from GitHub with:
# install.packages("devtools")
devtools::install_github("pmarcowski/scio")
- Visit OpenRouter.ai and create an account.
- Go to your dashboard and generate an API key.
- Set it in R:
Sys.setenv(OPENROUTER_API_KEY = "your_key_here")
.
For persistent use, add OPENROUTER_API_KEY="your_key_here"
to your .Renviron
file.
library(scio)
# summarize a data frame
get_summary(head(mtcars))
# summarize a character string
get_summary("This is some text to summarize.")
# summarize a ggplot object
library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
get_summary(p)
You can also embed summaries directly in R Markdown text, like so:
The data shows `r scio::get_summary(my_data)`
For setup and usage example, see the intro vignette.
Variable | What it controls | Default |
---|---|---|
OPENROUTER_API_KEY (req.) | Your API key for authentication | —must set |
OPENROUTER_MODEL | Model to use | "openai/gpt-4.1-mini" |
OPENROUTER_TOKEN_LIMIT | Max tokens for the summary | 500 |
OPENROUTER_SYSTEM_MESSAGE | System prompt for role-setting | Internal default (see docs) |
OPENROUTER_INSTRUCTION | User instruction prompt | Internal default (see docs) |
OPENROUTER_HTTP_REFERER | Custom HTTP Referer header | "scio" |
OPENROUTER_X_TITLE | Custom X-Title header | "R Summaries via scio" |
Feature requests and bug reports are welcome. Please open an issue.
This project is licensed under GPL-3.0 - see the LICENSE file for details.
- Built on the OpenRouter API