tests/testthat/test-chat-utils.R

test_that("as_chat() takes string or chat", {
  chat <- chat_openai_test()
  expect_equal(as_chat(chat), chat)

  expect_equal(as_chat("openai/gpt-4.1-nano"), chat("openai/gpt-4.1-nano"))

  chat <- 1
  expect_snapshot(as_chat(chat), error = TRUE)
})

Try the ellmer package in your browser

Any scripts or data that you put into this service are public.

ellmer documentation built on July 14, 2026, 1:07 a.m.