TypeSafeAPI.Model (TypeSafe AI v0.1.0-alpha.3)

Copy Markdown View Source

A model available to the account, as listed by TypeSafeAPI.models/1.

release_date is a Date, because that is what the endpoint means: the OpenAPI schema describes it as "Model release date, formatted as YYYY-MM-DD", even though the live API sends a full ISO 8601 datetime today. A datetime is reduced to the calendar date it carries, without shifting it into UTC, so a model released on the 15th at 20:00-07:00 does not report the 16th. A value this library cannot parse as a date at all — the "latest" alias, say — leaves release_date nil.

release_date_raw is the string exactly as it arrived, so nothing is lost to the normalization. raw is the whole entry, so a field this struct does not model yet (a context window, a deprecation date) is reachable without waiting for a release; this endpoint is reverse-engineered from the official Python SDK, so it is the most likely one to grow fields.

description is required and non-nullable in the spec, but a non-string one degrades to nil here rather than failing the call. It stays in raw.

Summary

Functions

Decodes one entry of the models array.

Types

t()

@type t() :: %TypeSafeAPI.Model{
  description: String.t() | nil,
  name: String.t(),
  raw: map(),
  release_date: Date.t() | nil,
  release_date_raw: String.t() | nil
}

Functions

decode(raw)

@spec decode(term()) :: {:ok, t()} | :error

Decodes one entry of the models array.

Only a string name is required; TypeSafeAPI.Models.list/2 skips an entry that returns :error rather than failing the whole list.