diff --git a/.gitignore b/.gitignore
index 0bbd4a9..82f1ad5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-/docs/
/lib/
/bin/
/.shards/
diff --git a/README.md b/README.md
index 4c8656a..6b126c4 100644
--- a/README.md
+++ b/README.md
@@ -18,20 +18,30 @@ Client for the Anthropic API. Supports tool use and running those tools automati
```crystal
require "anthropic"
+```
+
+The main entrypoint is via the `Anthropic::Client`. You can instantiate it explicitly with an API key:
-# Instantiate it explicitly with an API key
+```crystal
claude = Anthropic::Client.new("sk-and-api-03-asdfasdfasdf")
+```
+
+Or you can omit the API key to automatically read it from the `ANTHROPIC_API_KEY` environment variable:
-# If you omit the API key, it will be retrieved from the
-# ANTHROPIC_API_KEY environment variable
+```crystal
claude = Anthropic::Client.new
+```
-puts claude.messages.create(
+Next, use the `Anthropic::Messages#create` method to send your prompt:
+
+```crystal
+response = claude.messages.create(
# Pass a string representing the model name, or retrieve the full model
# name via the shorthand with Anthropic.model_name.
model: Anthropic.model_name(:sonnet),
- # Define a system prompt if you want to give the AI a persona to use
+ # Define a system prompt if you want to give the AI a persona to use or some
+ # instructions on how to respond to the prompt.
system: "You are an expert in the Crystal programming language",
# You can pass the full list of messages, including messages it gave you
@@ -50,10 +60,12 @@ puts claude.messages.create(
# will be more stochastic.
temperature: 0.5,
- # You can pass an `Array` of tools to give the client a way to run custom code
- # in your app. See below for additional information on how to define those.
- # The more tools you pass in with a request, the more tokens the request will
- # use, so you should keep this to a reasonable size.
+ # You can optionally pass an `Array` of tools to give the client a way to run
+ # custom code in your app. See below for additional information on how to
+ # define those. The more tools you pass in with a request, the more tokens the
+ # request will use, so you should keep this to a reasonable size.
+ #
+ # If no tools are specified, the model won't try to run any.
tools: [
GitHubUserLookup,
GoogleDriveSearch.new(google_oauth_token),
diff --git a/docs/404.html b/docs/404.html
new file mode 100644
index 0000000..be79971
--- /dev/null
+++ b/docs/404.html
@@ -0,0 +1,422 @@
+
+
+
The Anthropic::Client is the entrypoint for using the Anthropic API in
+Crystal.
+
claude =Anthropic::Client.new # get API key from the ENV
+puts claude.messages.create(
+ model: Anthropic.model_name(:haiku),
+ messages: [Anthropic::Message.new("Write a haiku about the Crystal programming language")],
+ max_tokens: 4096,
+)
+# Sparkling Crystal code,
+# Elegant and swift syntax,
+# Shines with precision.
+
The client is concurrency-safe, so you don't need to wrap requests in a mutex
+or manage a connection pool yourself.
Instantiate a new client with the API key provided either directly or via
+the ANTHROPIC_API_KEY environment variable. You can optionally provide a
+base URI to connect to if you are using a different but compatible API
+provider.
This is an array of content blocks, each of which has a #type that determines
+its shape. Currently, the only #type in responses is "text".
+
Example:
+
[{ "type": "text", "text": "Hi, I'm Claude." }]
+
If the request input messages ended with an assistant turn, then the
+response #content will continue directly from that last turn. You can use this
+to constrain the model's output.
+
For example, if the input messages were:
+
[
+ {
+ "role": "user",
+ "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
+ },
+ { "role": "assistant", "content": "The best answer is (" }
+]
Anthropic's API bills and rate-limits by token counts, as tokens represent the
+underlying cost to our systems.
+
Under the hood, the API transforms requests into a format suitable for the
+model. The model's output then goes through a parsing stage before becoming an
+API response. As a result, the token counts in #usage will not match one-to-one
+with the exact visible content of an API request or response.
+
For example, output_tokens will be non-zero, even for an empty string response
+from Claude.
Returns a String representation of this enum member.
+In the case of regular enums, this is just the name of the member.
+In the case of flag enums, it's the names joined by vertical bars, or "None",
+if the value is zero.
+
If an enum's value doesn't match a member's value, the raw value
+is returned as a string.
The main entrypoint is via the Anthropic::Client. You can instantiate it explicitly with an API key:
+
claude =Anthropic::Client.new("sk-and-api-03-asdfasdfasdf")
+
Or you can omit the API key to automatically read it from the ANTHROPIC_API_KEY environment variable:
+
claude =Anthropic::Client.new
+
Next, use the Anthropic::Messages#create method to send your prompt:
+
response = claude.messages.create(
+ # Pass a string representing the model name, or retrieve the full model
+ # name via the shorthand with Anthropic.model_name.
+ model: Anthropic.model_name(:sonnet),
+
+ # Define a system prompt if you want to give the AI a persona to use or some
+ # instructions on how to respond to the prompt.
+ system: "You are an expert in the Crystal programming language",
+
+ # You can pass the full list of messages, including messages it gave you
+ # back.
+ messages: [
+ Anthropic::Message.new("What makes Crystal the best programming language?")
+ ],
+
+ # The maximum number of tokens the AI will try to respond with. Keep this low
+ # if you're feeding untrusted prompts.
+ max_tokens: 4096,
+
+ # A floating-point value between 0.0 and 1.0 representing how creative the
+ # response should be. Lower values (closer to 0.0) will be more deterministic
+ # and should be used for analytical prompts. Higher values (closer to 1.0)
+ # will be more stochastic.
+ temperature: 0.5,
+
+ # You can optionally pass an `Array` of tools to give the client a way to run
+ # custom code in your app. See below for additional information on how to
+ # define those. The more tools you pass in with a request, the more tokens the
+ # request will use, so you should keep this to a reasonable size.
+ #
+ # By default, no tools are included.
+ tools: [
+ GitHubUserLookup,
+ GoogleDriveSearch.new(google_oauth_token),
+ ],
+
+ # Uncomment the following line to avoid automatically running the tool
+ # selected by the model.
+ # run_tools: false,
+
+ # Limit the token selection to the "top k" tokens. If you need this
+ # explanation, chances are you should use `temperature` instead. That's not a
+ # dig — I've never used it myself.
+ # top_k: 10,
+
+ # P value for nucleus sampling. If you're dialing in your prompts with the
+ # `temperature` argument, you should ignore this one. I've never used this
+ # one, either.
+ # top_p: 0.1234,
+)
+
You can also pass images to the model:
+
puts claude
+ .messages
+ .create(
+ # You should generally use the Haiku model when dealing with images since
+ # they tend to consume quite a few tokens.
+ model: Anthropic.model_name(:haiku),
+ messages: [
+ Anthropic::Message.new(
+ content: Array(Anthropic::MessageContent){
+ # Images are base64-encoded and sent to the model
+ Anthropic::Image.base64(:jpeg, File.read("/path/to/image.jpeg")),
+ Anthropic::Text.new("Describe this image"),
+ },
+ ),
+ ],
+ max_tokens: 4096,
+ # Using a more deterministic response about the image
+ temperature: 0.1,
+ )
Tools are objects that the Anthropic models can use to invoke your code. You
+can define them easily with a struct that inherits from
+Anthropic::Tool::Handler.
+
structGitHubUserLookup<Anthropic::Tool::Handler
+ # Define any properties required for this tool as getters. Claude will
+ # provide them if it can based on the user's question.
+
+ # The username/login for the GitHub user, used to fetch the user from the
+ # GitHub API.
+ getter username : String
+
+ # This is the description that lets the model know when and how to use your
+ # code. It's basically the documentation the model will use. The more
+ # descriptive this is, the more confidence the model will have in invoking
+ # it, but it does consume tokens.
+ defself.description
+ <<-EOF
+ Retrieves the GitHub user with the given username. The username may also
+ be referred to as a "login". The username can only contain letters,
+ numbers, underscores, and dashes.
+
+ The tool will return the current data about the GitHub user with that
+ username. It should be used when the user asks about that particular
+ GitHub user. It will not provide information about GitHub repositories
+ or any issues, pull requests, commits, or other content on GitHub created
+ by that GitHub user.
+ EOF
+ end
+
+ # This is the method the client will use to invoke this tool. The return value
+ # of this method will be serialized as JSON and sent over the wire as the
+ # tool-use result
+ defcall
+ User.from_json HTTP::Client.get(URI.parse("https://api.github.com/users/#{username}")).body
+ end
+
+ # The definition for the value we want to send back to the model. Every
+ # property specified here will consume tokens, so only define getters that
+ # will provide useful context to the model.
+ structUser
+ includeJSON::Serializable
+
+ getter login : String
+ getter name : String
+ getter company : String?
+ getter location : String
+ getter bio : String?
+ getter public_repos : Int64
+ getter public_gists : Int64
+ getter followers : Int64
+ getter following : Int64
+ end
+end
+
You can also define tools without inheriting from Anthropic::Tool::Handler. That type simply implements the following API on the tool object (instance or type) being passed in:
+
+
name : String
+
description : String
+
json_schema, which returns a to_json-able object
+
parse, which returns a call-able object which returns a to_json-able object
+
+
Here is an example of a tool that searches a user's Google Drive (via the jgaskins/google shard) using the provided query. Claude will generate the query and pass it to the tool,
+
require"google"
+require"google/drive"
+
+record GoogleDriveSearch, token : Stringdo
+ GOOGLE=Google::Client.new(
+ client_id: ENV["GOOGLE_CLIENT_ID"],
+ client_secret: ENV["GOOGLE_CLIENT_SECRET"],
+ redirect_uri: URI.parse("https://example.com/oauth2/google"),
+ )
+
+ defdescription
+ "Search Google for a user's documents with the given search query. You must use the Google Drive API query string format."
+ end
+
+ defname
+ "GoogleDriveSearch"
+ end
+
+ defjson_schema
+ # The `json_schema` class method is provided on all `JSON::Serializable`
+ # types by the `spider-gazelle/json-schema` shard.
+ Query.json_schema
+ end
+
+ defparse(json : String)
+ query =Query.from_json json
+ query.search =self
+ query
+ end
+
+ defcall(query : String)
+ files =GOOGLE
+ .drive
+ .files
+ .list(
+ token: token,
+ q: "(#{query}) and mimeType contains 'application/vnd.google-apps'",
+ limit: 10,
+ )
+ .to_a
+
+ array =Array(FileInfo).new(files.size)
+ # Requires this PR to be released, or the equivalent monkeypatch:
+ # https://github.com/crystal-lang/crystal/pull/14837
+ WaitGroup.wait do|wg|
+ mutex =Mutex.new
+ files.each do|file|
+ wg.spawn do
+ file_info =FileInfo.new(
+ id: file.id,
+ name: file.name,
+ content: GOOGLE.drive.files.export(file, "text/plain", token, &.gets_to_end),
+ link: file.web_view_link,
+ )
+
+ mutex.synchronize do
+ array << file_info
+ end
+ end
+ end
+ end
+
+ array
+ end
+
+ structFileInfo
+ includeJSON::Serializable
+
+ getter id : String
+ getter name : String
+ getter content : String
+ getter link : String
+
+ definitialize(@id, @name, @content, @link)
+ end
+ end
+
+ structQuery
+ includeJSON::Serializable
+
+ getter query : String
+ @[JSON::Field(ignore: true)]
+ protected property! search : GoogleDriveSearch
+
+ defcall
+ search.call(query)
+ end
+ end
+end
+
See the example code above to find out how to pass them to the model.
+
+
diff --git a/docs/index.json b/docs/index.json
new file mode 100644
index 0000000..c3c204b
--- /dev/null
+++ b/docs/index.json
@@ -0,0 +1 @@
+{"repository_name":"anthropic","body":"# anthropic\n\nClient for the Anthropic API. Supports tool use and running those tools automatically.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n anthropic:\n github: jgaskins/anthropic\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"anthropic\"\n```\n\nThe main entrypoint is via the `Anthropic::Client`. You can instantiate it explicitly with an API key:\n\n```crystal\nclaude = Anthropic::Client.new(\"sk-and-api-03-asdfasdfasdf\")\n```\n\nOr you can omit the API key to automatically read it from the `ANTHROPIC_API_KEY` environment variable:\n\n```crystal\nclaude = Anthropic::Client.new\n```\n\nNext, use the `Anthropic::Messages#create` method to send your prompt:\n\n```crystal\nresponse = claude.messages.create(\n # Pass a string representing the model name, or retrieve the full model\n # name via the shorthand with Anthropic.model_name.\n model: Anthropic.model_name(:sonnet),\n\n # Define a system prompt if you want to give the AI a persona to use or some\n # instructions on how to respond to the prompt.\n system: \"You are an expert in the Crystal programming language\",\n\n # You can pass the full list of messages, including messages it gave you\n # back.\n messages: [\n Anthropic::Message.new(\"What makes Crystal the best programming language?\")\n ],\n\n # The maximum number of tokens the AI will try to respond with. Keep this low\n # if you're feeding untrusted prompts.\n max_tokens: 4096,\n\n # A floating-point value between 0.0 and 1.0 representing how creative the\n # response should be. Lower values (closer to 0.0) will be more deterministic\n # and should be used for analytical prompts. Higher values (closer to 1.0)\n # will be more stochastic.\n temperature: 0.5,\n\n # You can optionally pass an `Array` of tools to give the client a way to run\n # custom code in your app. See below for additional information on how to\n # define those. The more tools you pass in with a request, the more tokens the\n # request will use, so you should keep this to a reasonable size.\n #\n # By default, no tools are included.\n tools: [\n GitHubUserLookup,\n GoogleDriveSearch.new(google_oauth_token),\n ],\n\n # Uncomment the following line to avoid automatically running the tool\n # selected by the model.\n # run_tools: false,\n\n # Limit the token selection to the \"top k\" tokens. If you need this\n # explanation, chances are you should use `temperature` instead. That's not a\n # dig — I've never used it myself.\n # top_k: 10,\n\n # P value for nucleus sampling. If you're dialing in your prompts with the\n # `temperature` argument, you should ignore this one. I've never used this\n # one, either.\n # top_p: 0.1234,\n)\n```\n\nYou can also pass images to the model:\n\n```crystal\nputs claude\n .messages\n .create(\n # You should generally use the Haiku model when dealing with images since\n # they tend to consume quite a few tokens.\n model: Anthropic.model_name(:haiku),\n messages: [\n Anthropic::Message.new(\n content: Array(Anthropic::MessageContent){\n # Images are base64-encoded and sent to the model\n Anthropic::Image.base64(:jpeg, File.read(\"/path/to/image.jpeg\")),\n Anthropic::Text.new(\"Describe this image\"),\n },\n ),\n ],\n max_tokens: 4096,\n # Using a more deterministic response about the image\n temperature: 0.1,\n )\n```\n\n### Defining tools\n\nTools are objects that the Anthropic models can use to invoke your code. You\ncan define them easily with a `struct` that inherits from\n`Anthropic::Tool::Handler`.\n\n```crystal\nstruct GitHubUserLookup < Anthropic::Tool::Handler\n # Define any properties required for this tool as getters. Claude will\n # provide them if it can based on the user's question.\n\n # The username/login for the GitHub user, used to fetch the user from the\n # GitHub API.\n getter username : String\n\n # This is the description that lets the model know when and how to use your\n # code. It's basically the documentation the model will use. The more\n # descriptive this is, the more confidence the model will have in invoking\n # it, but it does consume tokens.\n def self.description\n <<-EOF\n Retrieves the GitHub user with the given username. The username may also\n be referred to as a \"login\". The username can only contain letters,\n numbers, underscores, and dashes.\n\n The tool will return the current data about the GitHub user with that\n username. It should be used when the user asks about that particular\n GitHub user. It will not provide information about GitHub repositories\n or any issues, pull requests, commits, or other content on GitHub created\n by that GitHub user.\n EOF\n end\n\n # This is the method the client will use to invoke this tool. The return value\n # of this method will be serialized as JSON and sent over the wire as the\n # tool-use result\n def call\n User.from_json HTTP::Client.get(URI.parse(\"https://api.github.com/users/#{username}\")).body\n end\n\n # The definition for the value we want to send back to the model. Every\n # property specified here will consume tokens, so only define getters that\n # will provide useful context to the model.\n struct User\n include JSON::Serializable\n\n getter login : String\n getter name : String\n getter company : String?\n getter location : String\n getter bio : String?\n getter public_repos : Int64\n getter public_gists : Int64\n getter followers : Int64\n getter following : Int64\n end\nend\n```\n\nYou can also define tools without inheriting from `Anthropic::Tool::Handler`. That type simply implements the following API on the tool object (instance or type) being passed in:\n\n- `name : String`\n- `description : String`\n- `json_schema`, which returns a `to_json`-able object\n- `parse`, which returns a `call`-able object which returns a `to_json`-able object\n\nHere is an example of a tool that searches a user's Google Drive (via the [`jgaskins/google`](https://github.com/jgaskins/google) shard) using the provided query. Claude will generate the query and pass it to the tool, \n\n```crystal\nrequire \"google\"\nrequire \"google/drive\"\n\nrecord GoogleDriveSearch, token : String do\n GOOGLE = Google::Client.new(\n client_id: ENV[\"GOOGLE_CLIENT_ID\"],\n client_secret: ENV[\"GOOGLE_CLIENT_SECRET\"],\n redirect_uri: URI.parse(\"https://example.com/oauth2/google\"),\n )\n\n def description\n \"Search Google for a user's documents with the given search query. You must use the Google Drive API query string format.\"\n end\n\n def name\n \"GoogleDriveSearch\"\n end\n\n def json_schema\n # The `json_schema` class method is provided on all `JSON::Serializable`\n # types by the `spider-gazelle/json-schema` shard.\n Query.json_schema\n end\n\n def parse(json : String)\n query = Query.from_json json\n query.search = self\n query\n end\n\n def call(query : String)\n files = GOOGLE\n .drive\n .files\n .list(\n token: token,\n q: \"(#{query}) and mimeType contains 'application/vnd.google-apps'\",\n limit: 10,\n )\n .to_a\n\n array = Array(FileInfo).new(files.size)\n # Requires this PR to be released, or the equivalent monkeypatch:\n # https://github.com/crystal-lang/crystal/pull/14837\n WaitGroup.wait do |wg|\n mutex = Mutex.new\n files.each do |file|\n wg.spawn do\n file_info = FileInfo.new(\n id: file.id,\n name: file.name,\n content: GOOGLE.drive.files.export(file, \"text/plain\", token, &.gets_to_end),\n link: file.web_view_link,\n )\n\n mutex.synchronize do\n array << file_info\n end\n end\n end\n end\n\n array\n end\n\n struct FileInfo\n include JSON::Serializable\n\n getter id : String\n getter name : String\n getter content : String\n getter link : String\n\n def initialize(@id, @name, @content, @link)\n end\n end\n\n struct Query\n include JSON::Serializable\n\n getter query : String\n @[JSON::Field(ignore: true)]\n protected property! search : GoogleDriveSearch\n\n def call\n search.call(query)\n end\n end\nend\n```\n\nSee the example code above to find out how to pass them to the model.\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Jamie Gaskins](https://github.com/jgaskins) - creator and maintainer\n","program":{"html_id":"anthropic/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"anthropic","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"anthropic/Anthropic","path":"Anthropic.html","kind":"module","full_name":"Anthropic","name":"Anthropic","abstract":false,"locations":[{"filename":"src/api.cr","line_number":3,"url":null},{"filename":"src/error.cr","line_number":1,"url":null},{"filename":"src/event_source.cr","line_number":6,"url":null},{"filename":"src/message_content.cr","line_number":5,"url":null},{"filename":"src/messages.cr","line_number":5,"url":null},{"filename":"src/model.cr","line_number":1,"url":null},{"filename":"src/resource.cr","line_number":3,"url":null},{"filename":"src/tool.cr","line_number":3,"url":null},{"filename":"src/version.cr","line_number":1,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\""}],"class_methods":[{"html_id":"model_name(model:Model)-class-method","name":"model_name","abstract":false,"args":[{"name":"model","external_name":"model","restriction":"Model"}],"args_string":"(model : Model)","args_html":"(model : Model)","location":{"filename":"src/model.cr","line_number":9,"url":null},"def":{"name":"model_name","args":[{"name":"model","external_name":"model","restriction":"Model"}],"visibility":"Public","body":"MODELS[model]"}},{"html_id":"tool(input_type,description:String|Nil=input_type.description,*,name:String=input_type.name):Tool-class-method","name":"tool","abstract":false,"args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"args_string":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","args_html":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","location":{"filename":"src/tool.cr","line_number":16,"url":null},"def":{"name":"tool","args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"splat_index":2,"return_type":"Tool","visibility":"Public","body":"Tool.new(name: name, description: description, input_type: input_type)"}},{"html_id":"tools(array:Array(Tool))-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"args_string":"(array : Array(Tool))","args_html":"(array : Array(Tool))","location":{"filename":"src/tool.cr","line_number":8,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"visibility":"Public","body":"array"}},{"html_id":"tools(array:Enumerable)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"args_string":"(array : Enumerable)","args_html":"(array : Enumerable)","location":{"filename":"src/tool.cr","line_number":4,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"visibility":"Public","body":"array.map do |handler|\n tool(handler)\nend"}},{"html_id":"tools(array:Nil)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Nil"}],"args_string":"(array : Nil)","args_html":"(array : Nil)","location":{"filename":"src/tool.cr","line_number":12,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Nil"}],"visibility":"Public","body":"[] of Tool(Tool::Handler.class)"}}],"types":[{"html_id":"anthropic/Anthropic/Client","path":"Anthropic/Client.html","kind":"class","full_name":"Anthropic::Client","name":"Client","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/client.cr","line_number":27,"url":null},{"filename":"src/messages.cr","line_number":188,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"doc":"The `Anthropic::Client` is the entrypoint for using the Anthropic API in\nCrystal.\n\n```\nclaude = Anthropic::Client.new # get API key from the ENV\nputs claude.messages.create(\n model: Anthropic.model_name(:haiku),\n messages: [Anthropic::Message.new(\"Write a haiku about the Crystal programming language\")],\n max_tokens: 4096,\n)\n# Sparkling Crystal code,\n# Elegant and swift syntax,\n# Shines with precision.\n```\n\nThe client is concurrency-safe, so you don't need to wrap requests in a mutex\nor manage a connection pool yourself.","summary":"
The Anthropic::Client is the entrypoint for using the Anthropic API in Crystal.
","constructors":[{"html_id":"new(api_key:String=ENV[\"ANTHROPIC_API_KEY\"],base_uri:URI=URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\",\"https://api.anthropic.com\")),log:Log=Log.for(self.class))-class-method","name":"new","doc":"Instantiate a new client with the API key provided either directly or via\nthe `ANTHROPIC_API_KEY` environment variable. You can optionally provide a\nbase URI to connect to if you are using a different but compatible API\nprovider.","summary":"
Instantiate a new client with the API key provided either directly or via the ANTHROPIC_API_KEY environment variable.
","abstract":false,"args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"args_string":"(api_key : String = ENV[\"ANTHROPIC_API_KEY\"], base_uri : URI = URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\")), log : Log = Log.for(self.class))","args_html":"(api_key : String = ENV["ANTHROPIC_API_KEY"], base_uri : URI = URI.parse(ENV.fetch("ANTHROPIC_BASE_URL", "https://api.anthropic.com")), log : Log = Log.for(self.class))","location":{"filename":"src/client.cr","line_number":35,"url":null},"def":{"name":"new","args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"visibility":"Public","body":"_ = allocate\n_.initialize(api_key, base_uri, log)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"api_key:String-instance-method","name":"api_key","abstract":false,"location":{"filename":"src/client.cr","line_number":28,"url":null},"def":{"name":"api_key","return_type":"String","visibility":"Public","body":"@api_key"}},{"html_id":"base_uri:URI-instance-method","name":"base_uri","abstract":false,"location":{"filename":"src/client.cr","line_number":29,"url":null},"def":{"name":"base_uri","return_type":"URI","visibility":"Public","body":"@base_uri"}},{"html_id":"messages-instance-method","name":"messages","abstract":false,"location":{"filename":"src/messages.cr","line_number":189,"url":null},"def":{"name":"messages","visibility":"Public","body":"Messages.new(self)"}}]},{"html_id":"anthropic/Anthropic/ContentBlockDelta","path":"Anthropic/ContentBlockDelta.html","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":114,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"delta:TextDelta-instance-method","name":"delta","abstract":false,"location":{"filename":"src/event_source.cr","line_number":116,"url":null},"def":{"name":"delta","return_type":"TextDelta","visibility":"Public","body":"@delta"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":115,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}]},{"html_id":"anthropic/Anthropic/ContentBlockStart","path":"Anthropic/ContentBlockStart.html","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":118,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content_block:ContentBlock|Nil-instance-method","name":"content_block","abstract":false,"location":{"filename":"src/event_source.cr","line_number":120,"url":null},"def":{"name":"content_block","return_type":"ContentBlock | ::Nil","visibility":"Public","body":"@content_block"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":119,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}],"types":[{"html_id":"anthropic/Anthropic/ContentBlockStart/ContentBlock","path":"Anthropic/ContentBlockStart/ContentBlock.html","kind":"struct","full_name":"Anthropic::ContentBlockStart::ContentBlock","name":"ContentBlock","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":121,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":126,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any|Nil-instance-method","name":"input","abstract":false,"location":{"filename":"src/event_source.cr","line_number":128,"url":null},"def":{"name":"input","return_type":"JSON::Any | ::Nil","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/event_source.cr","line_number":127,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}},{"html_id":"type:GeneratedMessage::Content::Type|Nil-instance-method","name":"type","abstract":false,"location":{"filename":"src/event_source.cr","line_number":124,"url":null},"def":{"name":"type","return_type":"GeneratedMessage::Content::Type | ::Nil","visibility":"Public","body":"@type"}}]}]},{"html_id":"anthropic/Anthropic/ContentBlockStop","path":"Anthropic/ContentBlockStop.html","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":131,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Error","path":"Anthropic/Error.html","kind":"class","full_name":"Anthropic::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":2,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/Error/APIError","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError"},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError"},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError"},{"html_id":"anthropic/Anthropic/Error/NotFoundError","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError"},{"html_id":"anthropic/Anthropic/Error/OverloadedError","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError"},{"html_id":"anthropic/Anthropic/Error/PermissionError","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError"},{"html_id":"anthropic/Anthropic/Error/RateLimitError","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"from_response_body(body:String)-class-method","name":"from_response_body","abstract":false,"args":[{"name":"body","external_name":"body","restriction":"String"}],"args_string":"(body : String)","args_html":"(body : String)","location":{"filename":"src/error.cr","line_number":3,"url":null},"def":{"name":"from_response_body","args":[{"name":"body","external_name":"body","restriction":"String"}],"visibility":"Public","body":"response = Response.from_json(body)\nTYPE_MAP[response.error.type].new(response.error.message)\n"}}],"constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/error.cr","line_number":8,"url":null},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"types":[{"html_id":"anthropic/Anthropic/Error/APIError","path":"Anthropic/Error/APIError.html","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":50,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","path":"Anthropic/Error/AuthenticationError.html","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":38,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","path":"Anthropic/Error/InvalidRequestError.html","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":35,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/NotFoundError","path":"Anthropic/Error/NotFoundError.html","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":44,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/OverloadedError","path":"Anthropic/Error/OverloadedError.html","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":53,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/PermissionError","path":"Anthropic/Error/PermissionError.html","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":41,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/RateLimitError","path":"Anthropic/Error/RateLimitError.html","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":47,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/Response","path":"Anthropic/Error/Response.html","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":56,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"error:Error-instance-method","name":"error","abstract":false,"location":{"filename":"src/error.cr","line_number":60,"url":null},"def":{"name":"error","return_type":"Error","visibility":"Public","body":"@error"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":59,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Error/Response/Error","path":"Anthropic/Error/Response/Error.html","kind":"struct","full_name":"Anthropic::Error::Response::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error/Response","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"message:String-instance-method","name":"message","abstract":false,"location":{"filename":"src/error.cr","line_number":66,"url":null},"def":{"name":"message","return_type":"String","visibility":"Public","body":"@message"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":65,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]}]}]},{"html_id":"anthropic/Anthropic/Event","path":"Anthropic/Event.html","kind":"struct","full_name":"Anthropic::Event","name":"Event","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":99,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/ContentBlockDelta","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta"},{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},{"html_id":"anthropic/Anthropic/ContentBlockStop","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop"},{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},{"html_id":"anthropic/Anthropic/MessageStart","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart"},{"html_id":"anthropic/Anthropic/MessageStop","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop"},{"html_id":"anthropic/Anthropic/MessageStream","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream"},{"html_id":"anthropic/Anthropic/Ping","kind":"struct","full_name":"Anthropic::Ping","name":"Ping"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"new","visibility":"Public","body":"x = allocate\nif x.responds_to?(:finalize)\n ::GC.add_finalizer(x)\nend\nx\n"}}],"instance_methods":[{"html_id":"initialize-instance-method","name":"initialize","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"initialize","visibility":"Public","body":""}}],"macros":[{"html_id":"define(type)-macro","name":"define","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""}],"args_string":"(type)","args_html":"(type)","location":{"filename":"src/event_source.cr","line_number":103,"url":null},"def":{"name":"define","args":[{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":" struct \n{{ type }}\n < ::Anthropic::Event\n include Resource\n\n Event::TYPE_MAP[\n{{ type.stringify.underscore }}\n] = \n{{ type }}\n\n \n \n{{ yield }}\n\n \nend\n \n"}}]},{"html_id":"anthropic/Anthropic/EventMessage","path":"Anthropic/EventMessage.html","kind":"struct","full_name":"Anthropic::EventMessage","name":"EventMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":93,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(data:Array(String),event:String|Nil=nil,id:String|Nil=nil,retry:Int64|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"args_string":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","args_html":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"new","args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(data, event, id, retry)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@data.clone, @event.clone, @id.clone, @retry.clone)"}},{"html_id":"copy_with(data_data=@data,event_event=@event,id_id=@id,retry_retry=@retry)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"args_string":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","args_html":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"copy_with","args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"visibility":"Public","body":"self.class.new(_data, _event, _id, _retry)"}},{"html_id":"data:Array(String)-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"Array(String)","visibility":"Public","body":"@data"}},{"html_id":"event:String|Nil-instance-method","name":"event","abstract":false,"def":{"name":"event","return_type":"String | ::Nil","visibility":"Public","body":"@event"}},{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"retry:Int64|Nil-instance-method","name":"retry","abstract":false,"def":{"name":"retry","return_type":"Int64 | ::Nil","visibility":"Public","body":"@retry"}}]},{"html_id":"anthropic/Anthropic/EventSource","path":"Anthropic/EventSource.html","kind":"class","full_name":"Anthropic::EventSource","name":"EventSource","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":7,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(response:HTTP::Client::Response,last_id:Nil|String=nil)-class-method","name":"new","abstract":false,"args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"args_string":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","args_html":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","location":{"filename":"src/event_source.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(response, last_id)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"last_id:String|Nil-instance-method","name":"last_id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":9,"url":null},"def":{"name":"last_id","return_type":"String | ::Nil","visibility":"Public","body":"@last_id"}},{"html_id":"on_error(&on_error:NamedTuple(status_code:Int32,message:String)->):self-instance-method","name":"on_error","abstract":false,"location":{"filename":"src/event_source.cr","line_number":18,"url":null},"def":{"name":"on_error","yields":1,"block_arity":1,"block_arg":{"name":"on_error","external_name":"on_error","restriction":"(NamedTuple(status_code: Int32, message: String) ->)"},"return_type":"self","visibility":"Public","body":"@on_error = on_error\nself\n"}},{"html_id":"on_message(&on_message:EventMessage,self->):self-instance-method","name":"on_message","abstract":false,"location":{"filename":"src/event_source.cr","line_number":14,"url":null},"def":{"name":"on_message","yields":2,"block_arity":2,"block_arg":{"name":"on_message","external_name":"on_message","restriction":"(EventMessage, self ->)"},"return_type":"self","visibility":"Public","body":"@on_message = on_message\nself\n"}},{"html_id":"response:HTTP::Client::Response-instance-method","name":"response","abstract":false,"location":{"filename":"src/event_source.cr","line_number":8,"url":null},"def":{"name":"response","return_type":"HTTP::Client::Response","visibility":"Public","body":"@response"}},{"html_id":"run:Nil-instance-method","name":"run","abstract":false,"location":{"filename":"src/event_source.cr","line_number":26,"url":null},"def":{"name":"run","return_type":"Nil","visibility":"Public","body":"lines = [] of String\nio = response.body_io\nlast_message = nil\nloop do\n if @abort\n break\n end\n if line = io.gets\n else\n break\n end\n if line.empty? && (!lines.empty?)\n last_message = parse_event_message(lines)\n last_message.id.try do |id|\n @last_id = id\n end\n @on_message.try(&.call(last_message, self))\n lines.clear\n else\n lines << line\n end\nend\nif last_message\n if last_message.id.try(&.empty?) && @abort\n last_message.retry.try do |retry_after|\n sleep(retry_after / 1000)\n end\n end\nend\n"}},{"html_id":"stop:Nil-instance-method","name":"stop","abstract":false,"location":{"filename":"src/event_source.cr","line_number":22,"url":null},"def":{"name":"stop","return_type":"Nil","visibility":"Public","body":"@abort = true"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage","path":"Anthropic/GeneratedMessage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content:Array(MessageContent)-instance-method","name":"content","doc":"This is an array of content blocks, each of which has a `type` that determines\nits shape. Currently, the only `type` in responses is `\"text\"`.\n\nExample:\n\n```json\n[{ \"type\": \"text\", \"text\": \"Hi, I'm Claude.\" }]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the\nresponse `content` will continue directly from that last turn. You can use this\nto constrain the model's output.\n\nFor example, if the input `messages` were:\n\n```json\n[\n {\n \"role\": \"user\",\n \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n },\n { \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{ \"type\": \"text\", \"text\": \"B)\" }]\n```","summary":"
This is an array of content blocks, each of which has a #type that determines its shape.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":43,"url":null},"def":{"name":"content","return_type":"Array(MessageContent)","visibility":"Public","body":"if (value = @content).nil?\n @content = ([] of MessageContent)\nelse\n value\nend"}},{"html_id":"id:String-instance-method","name":"id","doc":"Unique object identifier.\n\nThe format and length of IDs may change over time.","summary":"
Unique object identifier.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":12,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"message_thread:Array(Message)-instance-method","name":"message_thread","doc":"Messages that were passed to the","summary":"
Messages that were passed to the
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":59,"url":null},"def":{"name":"message_thread","return_type":"Array(Message)","visibility":"Public","body":"if (value = @message_thread).nil?\n @message_thread = ([to_message])\nelse\n value\nend"}},{"html_id":"model:String-instance-method","name":"model","doc":"The model that handled the request.","summary":"
The model that handled the request.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":52,"url":null},"def":{"name":"model","return_type":"String","visibility":"Public","body":"@model"}},{"html_id":"role:Message::Role-instance-method","name":"role","doc":"Conversational role of the generated message. This will always be `:assistant`.","summary":"
Conversational role of the generated message.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":49,"url":null},"def":{"name":"role","return_type":"Message::Role","visibility":"Public","body":"@role"}},{"html_id":"stop_reason:StopReason|Nil-instance-method","name":"stop_reason","doc":"The reason that we stopped. This may be one the following values:\n\n- `:end_turn`: the model reached a natural stopping point\n- `:max_tokens`: we exceeded the requested `max_tokens` or the model's maximum\n- `:stop_sequence`: one of your provided custom `stop_sequences` was generated\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is\n`nil` in the `MessageStart` event and non-`nil` otherwise.","summary":"
The reason that we stopped.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":85,"url":null},"def":{"name":"stop_reason","return_type":"StopReason | ::Nil","visibility":"Public","body":"@stop_reason"}},{"html_id":"stop_sequence:String|Nil-instance-method","name":"stop_sequence","doc":"Which custom stop sequence was generated, if any. This value will be a non-\n`nil` string if one of your custom stop sequences was generated.","summary":"
Which custom stop sequence was generated, if any.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":56,"url":null},"def":{"name":"stop_sequence","return_type":"String | ::Nil","visibility":"Public","body":"@stop_sequence"}},{"html_id":"to_message-instance-method","name":"to_message","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":87,"url":null},"def":{"name":"to_message","visibility":"Public","body":"Message.new(role: role, content: content)"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":94,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"content.each do |item|\n io.puts(item)\nend"}},{"html_id":"type:String-instance-method","name":"type","doc":"Object type — for `Message`s, this is always `\"message\"`.","summary":"
Object type — for Messages, this is always "message".
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":46,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}},{"html_id":"usage:Usage-instance-method","name":"usage","doc":"Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the\nunderlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the\nmodel. The model's output then goes through a parsing stage before becoming an\nAPI response. As a result, the token counts in `usage` will not match one-to-one\nwith the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response\nfrom Claude.","summary":"
Billing and rate-limit usage.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":75,"url":null},"def":{"name":"usage","return_type":"Usage","visibility":"Public","body":"@usage"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","path":"Anthropic/GeneratedMessage/Content.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":100,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"subclasses":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text"},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":105,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"location = pull.location\ndiscriminator_value = nil\njson = String.build do |io|\n JSON.build(io) do |builder|\n builder.start_object\n pull.read_object do |key|\n if key == \"type\"\n value_kind = pull.kind\n case value_kind\n when .string?\n discriminator_value = pull.string_value\n when .int?\n discriminator_value = pull.int_value\n when .bool?\n discriminator_value = pull.bool_value\n else\n raise(::JSON::SerializableError.new(\"JSON discriminator field 'type' has an invalid value type of #{value_kind.to_s}\", to_s, nil, *location, nil))\n end\n builder.field(key, discriminator_value)\n pull.read_next\n else\n builder.field(key) do\n pull.read_raw(builder)\n end\n end\n end\n builder.end_object\n end\nend\nif discriminator_value.nil?\n raise(::JSON::SerializableError.new(\"Missing JSON discriminator field 'type'\", to_s, nil, *location, nil))\nend\ncase discriminator_value\nwhen \"text\"\n Text.from_json(json)\nwhen \"tool_use\"\n ToolUse.from_json(json)\nelse\n raise(::JSON::SerializableError.new(\"Unknown 'type' discriminator value: #{discriminator_value.inspect}\", to_s, nil, *location, nil))\nend\n"}}],"instance_methods":[{"html_id":"type:Type-instance-method","name":"type","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":103,"url":null},"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content/Type","path":"Anthropic/GeneratedMessage/Content/Type.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::Content::Type","name":"Type","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":110,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Text","name":"Text","value":"0"},{"id":"ToolUse","name":"ToolUse","value":"1"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"instance_methods":[{"html_id":"text?-instance-method","name":"text?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":111,"url":null},"def":{"name":"text?","visibility":"Public","body":"self == Text"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":112,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/StopReason","path":"Anthropic/GeneratedMessage/StopReason.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::StopReason","name":"StopReason","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":159,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"EndTurn","name":"EndTurn","value":"0"},{"id":"MaxTokens","name":"MaxTokens","value":"1"},{"id":"StopSequence","name":"StopSequence","value":"2"},{"id":"ToolUse","name":"ToolUse","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"instance_methods":[{"html_id":"end_turn?-instance-method","name":"end_turn?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":160,"url":null},"def":{"name":"end_turn?","visibility":"Public","body":"self == EndTurn"}},{"html_id":"max_tokens?-instance-method","name":"max_tokens?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":161,"url":null},"def":{"name":"max_tokens?","visibility":"Public","body":"self == MaxTokens"}},{"html_id":"stop_sequence?-instance-method","name":"stop_sequence?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":162,"url":null},"def":{"name":"stop_sequence?","visibility":"Public","body":"self == StopSequence"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":163,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","path":"Anthropic/GeneratedMessage/Text.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":116,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":116,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"text:String|Nil-instance-method","name":"text","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":117,"url":null},"def":{"name":"text","return_type":"String | ::Nil","visibility":"Public","body":"@text"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":119,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"if text = @text\n io.puts(text)\nend"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","path":"Anthropic/GeneratedMessage/ToolUse.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":126,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":126,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":127,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any-instance-method","name":"input","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":130,"url":null},"def":{"name":"input","return_type":"JSON::Any","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":128,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/PossibleSchema","path":"Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html","kind":"module","full_name":"Anthropic::GeneratedMessage::ToolUse::PossibleSchema","name":"PossibleSchema","abstract":false,"locations":[{"filename":"src/generated_message.cr","line_number":132,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"class_methods":[{"html_id":"from_json(json:JSON::PullParser):JSON::Any-class-method","name":"from_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"args_string":"(json : JSON::PullParser) : JSON::Any","args_html":"(json : JSON::PullParser) : JSON::Any","location":{"filename":"src/generated_message.cr","line_number":133,"url":null},"def":{"name":"from_json","args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"return_type":"JSON::Any","visibility":"Public","body":"hash = Hash(String, JSON::Any).new(json)\nresult = hash.fetch(\"properties\") do\n JSON::Any.new(nil)\nend\nif result.as_h?\n result\nelse\n JSON::Any.new(hash)\nend\n"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/Schema","path":"Anthropic/GeneratedMessage/ToolUse/Schema.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse::Schema","name":"Schema","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":145,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":146,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"properties:JSON::Any-instance-method","name":"properties","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":148,"url":null},"def":{"name":"properties","return_type":"JSON::Any","visibility":"Public","body":"@properties"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Usage","path":"Anthropic/GeneratedMessage/Usage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Usage","name":"Usage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":152,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"input_tokens:Int64-instance-method","name":"input_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":155,"url":null},"def":{"name":"input_tokens","return_type":"Int64","visibility":"Public","body":"@input_tokens"}},{"html_id":"output_tokens:Int64-instance-method","name":"output_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":156,"url":null},"def":{"name":"output_tokens","return_type":"Int64","visibility":"Public","body":"@output_tokens"}}]}]},{"html_id":"anthropic/Anthropic/Image","path":"Anthropic/Image.html","kind":"struct","full_name":"Anthropic::Image","name":"Image","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":39,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"base64(media_type:Source::MediaType,data:String)-class-method","name":"base64","abstract":false,"args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(media_type : Source::MediaType, data : String)","args_html":"(media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":43,"url":null},"def":{"name":"base64","args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"new(type: :base64, media_type: media_type, data: Base64.strict_encode(data))"}}],"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":39,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,type:Source::Type,media_type:Source::MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","args_html":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(type: type, media_type: media_type, data: data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"source:Source-instance-method","name":"source","abstract":false,"location":{"filename":"src/message_content.cr","line_number":41,"url":null},"def":{"name":"source","return_type":"Source","visibility":"Public","body":"@source"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":40,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source","path":"Anthropic/Image/Source.html","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":55,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Image","kind":"struct","full_name":"Anthropic::Image","name":"Image"},"constructors":[{"html_id":"new(type:Type,media_type:MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(type : Type, media_type : MediaType, data : String)","args_html":"(type : Type, media_type : MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, media_type, data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@type.clone, @media_type.clone, @data.clone)"}},{"html_id":"copy_with(type_type=@type,media_type_media_type=@media_type,data_data=@data)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"args_string":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","args_html":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"copy_with","args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"visibility":"Public","body":"self.class.new(_type, _media_type, _data)"}},{"html_id":"data:String-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"String","visibility":"Public","body":"@data"}},{"html_id":"media_type:MediaType-instance-method","name":"media_type","abstract":false,"def":{"name":"media_type","return_type":"MediaType","visibility":"Public","body":"@media_type"}},{"html_id":"type:Type-instance-method","name":"type","abstract":false,"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source/MediaType","path":"Anthropic/Image/Source/MediaType.html","kind":"enum","full_name":"Anthropic::Image::Source::MediaType","name":"MediaType","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"JPEG","name":"JPEG","value":"0"},{"id":"PNG","name":"PNG","value":"1"},{"id":"GIF","name":"GIF","value":"2"},{"id":"WEBP","name":"WEBP","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},"instance_methods":[{"html_id":"gif?-instance-method","name":"gif?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":65,"url":null},"def":{"name":"gif?","visibility":"Public","body":"self == GIF"}},{"html_id":"jpeg?-instance-method","name":"jpeg?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":63,"url":null},"def":{"name":"jpeg?","visibility":"Public","body":"self == JPEG"}},{"html_id":"png?-instance-method","name":"png?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":64,"url":null},"def":{"name":"png?","visibility":"Public","body":"self == PNG"}},{"html_id":"to_s-instance-method","name":"to_s","doc":"Returns a `String` representation of this enum member.\nIn the case of regular enums, this is just the name of the member.\nIn the case of flag enums, it's the names joined by vertical bars, or \"None\",\nif the value is zero.\n\nIf an enum's value doesn't match a member's value, the raw value\nis returned as a string.\n\n```\nColor::Red.to_s # => \"Red\"\nIOMode::None.to_s # => \"None\"\n(IOMode::Read | IOMode::Write).to_s # => \"Read | Write\"\n\nColor.new(10).to_s # => \"10\"\n```","summary":"
Returns a String representation of this enum member.
'
+ );
+
+ function handleShortkeys(event) {
+ var element = event.target || event.srcElement;
+
+ if(element.tagName == "INPUT" || element.tagName == "TEXTAREA" || element.parentElement.tagName == "TEXTAREA"){
+ return;
+ }
+
+ switch(event.key) {
+ case "?":
+ usageModal.show();
+ break;
+
+ case "Escape":
+ usageModal.hide();
+ break;
+
+ case "s":
+ case "/":
+ if(usageModal.isVisible()) {
+ return;
+ }
+ event.stopPropagation();
+ navigator.focus();
+ performSearch();
+ break;
+ }
+ }
+
+ document.addEventListener('keyup', handleShortkeys);
+
+ var scrollToEntryFromLocationHash = function() {
+ var hash = window.location.hash;
+ if (hash) {
+ var targetAnchor = decodeURI(hash.substr(1));
+ var targetEl = document.getElementById(targetAnchor)
+ if (targetEl) {
+ targetEl.offsetParent.scrollTop = targetEl.offsetTop;
+ }
+ }
+ };
+ window.addEventListener("hashchange", scrollToEntryFromLocationHash, false);
+ scrollToEntryFromLocationHash();
+});
diff --git a/docs/search-index.js b/docs/search-index.js
new file mode 100644
index 0000000..62a7e8e
--- /dev/null
+++ b/docs/search-index.js
@@ -0,0 +1 @@
+crystal_doc_search_index_callback({"repository_name":"anthropic","body":"# anthropic\n\nClient for the Anthropic API. Supports tool use and running those tools automatically.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n anthropic:\n github: jgaskins/anthropic\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"anthropic\"\n```\n\nThe main entrypoint is via the `Anthropic::Client`. You can instantiate it explicitly with an API key:\n\n```crystal\nclaude = Anthropic::Client.new(\"sk-and-api-03-asdfasdfasdf\")\n```\n\nOr you can omit the API key to automatically read it from the `ANTHROPIC_API_KEY` environment variable:\n\n```crystal\nclaude = Anthropic::Client.new\n```\n\nNext, use the `Anthropic::Messages#create` method to send your prompt:\n\n```crystal\nresponse = claude.messages.create(\n # Pass a string representing the model name, or retrieve the full model\n # name via the shorthand with Anthropic.model_name.\n model: Anthropic.model_name(:sonnet),\n\n # Define a system prompt if you want to give the AI a persona to use or some\n # instructions on how to respond to the prompt.\n system: \"You are an expert in the Crystal programming language\",\n\n # You can pass the full list of messages, including messages it gave you\n # back.\n messages: [\n Anthropic::Message.new(\"What makes Crystal the best programming language?\")\n ],\n\n # The maximum number of tokens the AI will try to respond with. Keep this low\n # if you're feeding untrusted prompts.\n max_tokens: 4096,\n\n # A floating-point value between 0.0 and 1.0 representing how creative the\n # response should be. Lower values (closer to 0.0) will be more deterministic\n # and should be used for analytical prompts. Higher values (closer to 1.0)\n # will be more stochastic.\n temperature: 0.5,\n\n # You can optionally pass an `Array` of tools to give the client a way to run\n # custom code in your app. See below for additional information on how to\n # define those. The more tools you pass in with a request, the more tokens the\n # request will use, so you should keep this to a reasonable size.\n #\n # By default, no tools are included.\n tools: [\n GitHubUserLookup,\n GoogleDriveSearch.new(google_oauth_token),\n ],\n\n # Uncomment the following line to avoid automatically running the tool\n # selected by the model.\n # run_tools: false,\n\n # Limit the token selection to the \"top k\" tokens. If you need this\n # explanation, chances are you should use `temperature` instead. That's not a\n # dig — I've never used it myself.\n # top_k: 10,\n\n # P value for nucleus sampling. If you're dialing in your prompts with the\n # `temperature` argument, you should ignore this one. I've never used this\n # one, either.\n # top_p: 0.1234,\n)\n```\n\nYou can also pass images to the model:\n\n```crystal\nputs claude\n .messages\n .create(\n # You should generally use the Haiku model when dealing with images since\n # they tend to consume quite a few tokens.\n model: Anthropic.model_name(:haiku),\n messages: [\n Anthropic::Message.new(\n content: Array(Anthropic::MessageContent){\n # Images are base64-encoded and sent to the model\n Anthropic::Image.base64(:jpeg, File.read(\"/path/to/image.jpeg\")),\n Anthropic::Text.new(\"Describe this image\"),\n },\n ),\n ],\n max_tokens: 4096,\n # Using a more deterministic response about the image\n temperature: 0.1,\n )\n```\n\n### Defining tools\n\nTools are objects that the Anthropic models can use to invoke your code. You\ncan define them easily with a `struct` that inherits from\n`Anthropic::Tool::Handler`.\n\n```crystal\nstruct GitHubUserLookup < Anthropic::Tool::Handler\n # Define any properties required for this tool as getters. Claude will\n # provide them if it can based on the user's question.\n\n # The username/login for the GitHub user, used to fetch the user from the\n # GitHub API.\n getter username : String\n\n # This is the description that lets the model know when and how to use your\n # code. It's basically the documentation the model will use. The more\n # descriptive this is, the more confidence the model will have in invoking\n # it, but it does consume tokens.\n def self.description\n <<-EOF\n Retrieves the GitHub user with the given username. The username may also\n be referred to as a \"login\". The username can only contain letters,\n numbers, underscores, and dashes.\n\n The tool will return the current data about the GitHub user with that\n username. It should be used when the user asks about that particular\n GitHub user. It will not provide information about GitHub repositories\n or any issues, pull requests, commits, or other content on GitHub created\n by that GitHub user.\n EOF\n end\n\n # This is the method the client will use to invoke this tool. The return value\n # of this method will be serialized as JSON and sent over the wire as the\n # tool-use result\n def call\n User.from_json HTTP::Client.get(URI.parse(\"https://api.github.com/users/#{username}\")).body\n end\n\n # The definition for the value we want to send back to the model. Every\n # property specified here will consume tokens, so only define getters that\n # will provide useful context to the model.\n struct User\n include JSON::Serializable\n\n getter login : String\n getter name : String\n getter company : String?\n getter location : String\n getter bio : String?\n getter public_repos : Int64\n getter public_gists : Int64\n getter followers : Int64\n getter following : Int64\n end\nend\n```\n\nYou can also define tools without inheriting from `Anthropic::Tool::Handler`. That type simply implements the following API on the tool object (instance or type) being passed in:\n\n- `name : String`\n- `description : String`\n- `json_schema`, which returns a `to_json`-able object\n- `parse`, which returns a `call`-able object which returns a `to_json`-able object\n\nHere is an example of a tool that searches a user's Google Drive (via the [`jgaskins/google`](https://github.com/jgaskins/google) shard) using the provided query. Claude will generate the query and pass it to the tool, \n\n```crystal\nrequire \"google\"\nrequire \"google/drive\"\n\nrecord GoogleDriveSearch, token : String do\n GOOGLE = Google::Client.new(\n client_id: ENV[\"GOOGLE_CLIENT_ID\"],\n client_secret: ENV[\"GOOGLE_CLIENT_SECRET\"],\n redirect_uri: URI.parse(\"https://example.com/oauth2/google\"),\n )\n\n def description\n \"Search Google for a user's documents with the given search query. You must use the Google Drive API query string format.\"\n end\n\n def name\n \"GoogleDriveSearch\"\n end\n\n def json_schema\n # The `json_schema` class method is provided on all `JSON::Serializable`\n # types by the `spider-gazelle/json-schema` shard.\n Query.json_schema\n end\n\n def parse(json : String)\n query = Query.from_json json\n query.search = self\n query\n end\n\n def call(query : String)\n files = GOOGLE\n .drive\n .files\n .list(\n token: token,\n q: \"(#{query}) and mimeType contains 'application/vnd.google-apps'\",\n limit: 10,\n )\n .to_a\n\n array = Array(FileInfo).new(files.size)\n # Requires this PR to be released, or the equivalent monkeypatch:\n # https://github.com/crystal-lang/crystal/pull/14837\n WaitGroup.wait do |wg|\n mutex = Mutex.new\n files.each do |file|\n wg.spawn do\n file_info = FileInfo.new(\n id: file.id,\n name: file.name,\n content: GOOGLE.drive.files.export(file, \"text/plain\", token, &.gets_to_end),\n link: file.web_view_link,\n )\n\n mutex.synchronize do\n array << file_info\n end\n end\n end\n end\n\n array\n end\n\n struct FileInfo\n include JSON::Serializable\n\n getter id : String\n getter name : String\n getter content : String\n getter link : String\n\n def initialize(@id, @name, @content, @link)\n end\n end\n\n struct Query\n include JSON::Serializable\n\n getter query : String\n @[JSON::Field(ignore: true)]\n protected property! search : GoogleDriveSearch\n\n def call\n search.call(query)\n end\n end\nend\n```\n\nSee the example code above to find out how to pass them to the model.\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Jamie Gaskins](https://github.com/jgaskins) - creator and maintainer\n","program":{"html_id":"anthropic/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"anthropic","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"anthropic/Anthropic","path":"Anthropic.html","kind":"module","full_name":"Anthropic","name":"Anthropic","abstract":false,"locations":[{"filename":"src/api.cr","line_number":3,"url":null},{"filename":"src/error.cr","line_number":1,"url":null},{"filename":"src/event_source.cr","line_number":6,"url":null},{"filename":"src/message_content.cr","line_number":5,"url":null},{"filename":"src/messages.cr","line_number":5,"url":null},{"filename":"src/model.cr","line_number":1,"url":null},{"filename":"src/resource.cr","line_number":3,"url":null},{"filename":"src/tool.cr","line_number":3,"url":null},{"filename":"src/version.cr","line_number":1,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\""}],"class_methods":[{"html_id":"model_name(model:Model)-class-method","name":"model_name","abstract":false,"args":[{"name":"model","external_name":"model","restriction":"Model"}],"args_string":"(model : Model)","args_html":"(model : Model)","location":{"filename":"src/model.cr","line_number":9,"url":null},"def":{"name":"model_name","args":[{"name":"model","external_name":"model","restriction":"Model"}],"visibility":"Public","body":"MODELS[model]"}},{"html_id":"tool(input_type,description:String|Nil=input_type.description,*,name:String=input_type.name):Tool-class-method","name":"tool","abstract":false,"args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"args_string":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","args_html":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","location":{"filename":"src/tool.cr","line_number":16,"url":null},"def":{"name":"tool","args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"splat_index":2,"return_type":"Tool","visibility":"Public","body":"Tool.new(name: name, description: description, input_type: input_type)"}},{"html_id":"tools(array:Array(Tool))-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"args_string":"(array : Array(Tool))","args_html":"(array : Array(Tool))","location":{"filename":"src/tool.cr","line_number":8,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"visibility":"Public","body":"array"}},{"html_id":"tools(array:Enumerable)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"args_string":"(array : Enumerable)","args_html":"(array : Enumerable)","location":{"filename":"src/tool.cr","line_number":4,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"visibility":"Public","body":"array.map do |handler|\n tool(handler)\nend"}},{"html_id":"tools(array:Nil)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Nil"}],"args_string":"(array : Nil)","args_html":"(array : Nil)","location":{"filename":"src/tool.cr","line_number":12,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Nil"}],"visibility":"Public","body":"[] of Tool(Tool::Handler.class)"}}],"types":[{"html_id":"anthropic/Anthropic/Client","path":"Anthropic/Client.html","kind":"class","full_name":"Anthropic::Client","name":"Client","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/client.cr","line_number":27,"url":null},{"filename":"src/messages.cr","line_number":188,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"doc":"The `Anthropic::Client` is the entrypoint for using the Anthropic API in\nCrystal.\n\n```\nclaude = Anthropic::Client.new # get API key from the ENV\nputs claude.messages.create(\n model: Anthropic.model_name(:haiku),\n messages: [Anthropic::Message.new(\"Write a haiku about the Crystal programming language\")],\n max_tokens: 4096,\n)\n# Sparkling Crystal code,\n# Elegant and swift syntax,\n# Shines with precision.\n```\n\nThe client is concurrency-safe, so you don't need to wrap requests in a mutex\nor manage a connection pool yourself.","summary":"
The Anthropic::Client is the entrypoint for using the Anthropic API in Crystal.
","constructors":[{"html_id":"new(api_key:String=ENV[\"ANTHROPIC_API_KEY\"],base_uri:URI=URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\",\"https://api.anthropic.com\")),log:Log=Log.for(self.class))-class-method","name":"new","doc":"Instantiate a new client with the API key provided either directly or via\nthe `ANTHROPIC_API_KEY` environment variable. You can optionally provide a\nbase URI to connect to if you are using a different but compatible API\nprovider.","summary":"
Instantiate a new client with the API key provided either directly or via the ANTHROPIC_API_KEY environment variable.
","abstract":false,"args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"args_string":"(api_key : String = ENV[\"ANTHROPIC_API_KEY\"], base_uri : URI = URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\")), log : Log = Log.for(self.class))","args_html":"(api_key : String = ENV["ANTHROPIC_API_KEY"], base_uri : URI = URI.parse(ENV.fetch("ANTHROPIC_BASE_URL", "https://api.anthropic.com")), log : Log = Log.for(self.class))","location":{"filename":"src/client.cr","line_number":35,"url":null},"def":{"name":"new","args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"visibility":"Public","body":"_ = allocate\n_.initialize(api_key, base_uri, log)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"api_key:String-instance-method","name":"api_key","abstract":false,"location":{"filename":"src/client.cr","line_number":28,"url":null},"def":{"name":"api_key","return_type":"String","visibility":"Public","body":"@api_key"}},{"html_id":"base_uri:URI-instance-method","name":"base_uri","abstract":false,"location":{"filename":"src/client.cr","line_number":29,"url":null},"def":{"name":"base_uri","return_type":"URI","visibility":"Public","body":"@base_uri"}},{"html_id":"messages-instance-method","name":"messages","abstract":false,"location":{"filename":"src/messages.cr","line_number":189,"url":null},"def":{"name":"messages","visibility":"Public","body":"Messages.new(self)"}}]},{"html_id":"anthropic/Anthropic/ContentBlockDelta","path":"Anthropic/ContentBlockDelta.html","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":114,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"delta:TextDelta-instance-method","name":"delta","abstract":false,"location":{"filename":"src/event_source.cr","line_number":116,"url":null},"def":{"name":"delta","return_type":"TextDelta","visibility":"Public","body":"@delta"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":115,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}]},{"html_id":"anthropic/Anthropic/ContentBlockStart","path":"Anthropic/ContentBlockStart.html","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":118,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content_block:ContentBlock|Nil-instance-method","name":"content_block","abstract":false,"location":{"filename":"src/event_source.cr","line_number":120,"url":null},"def":{"name":"content_block","return_type":"ContentBlock | ::Nil","visibility":"Public","body":"@content_block"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":119,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}],"types":[{"html_id":"anthropic/Anthropic/ContentBlockStart/ContentBlock","path":"Anthropic/ContentBlockStart/ContentBlock.html","kind":"struct","full_name":"Anthropic::ContentBlockStart::ContentBlock","name":"ContentBlock","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":121,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":126,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any|Nil-instance-method","name":"input","abstract":false,"location":{"filename":"src/event_source.cr","line_number":128,"url":null},"def":{"name":"input","return_type":"JSON::Any | ::Nil","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/event_source.cr","line_number":127,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}},{"html_id":"type:GeneratedMessage::Content::Type|Nil-instance-method","name":"type","abstract":false,"location":{"filename":"src/event_source.cr","line_number":124,"url":null},"def":{"name":"type","return_type":"GeneratedMessage::Content::Type | ::Nil","visibility":"Public","body":"@type"}}]}]},{"html_id":"anthropic/Anthropic/ContentBlockStop","path":"Anthropic/ContentBlockStop.html","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":131,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Error","path":"Anthropic/Error.html","kind":"class","full_name":"Anthropic::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":2,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/Error/APIError","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError"},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError"},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError"},{"html_id":"anthropic/Anthropic/Error/NotFoundError","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError"},{"html_id":"anthropic/Anthropic/Error/OverloadedError","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError"},{"html_id":"anthropic/Anthropic/Error/PermissionError","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError"},{"html_id":"anthropic/Anthropic/Error/RateLimitError","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"from_response_body(body:String)-class-method","name":"from_response_body","abstract":false,"args":[{"name":"body","external_name":"body","restriction":"String"}],"args_string":"(body : String)","args_html":"(body : String)","location":{"filename":"src/error.cr","line_number":3,"url":null},"def":{"name":"from_response_body","args":[{"name":"body","external_name":"body","restriction":"String"}],"visibility":"Public","body":"response = Response.from_json(body)\nTYPE_MAP[response.error.type].new(response.error.message)\n"}}],"constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/error.cr","line_number":8,"url":null},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"types":[{"html_id":"anthropic/Anthropic/Error/APIError","path":"Anthropic/Error/APIError.html","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":50,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","path":"Anthropic/Error/AuthenticationError.html","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":38,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","path":"Anthropic/Error/InvalidRequestError.html","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":35,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/NotFoundError","path":"Anthropic/Error/NotFoundError.html","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":44,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/OverloadedError","path":"Anthropic/Error/OverloadedError.html","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":53,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/PermissionError","path":"Anthropic/Error/PermissionError.html","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":41,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/RateLimitError","path":"Anthropic/Error/RateLimitError.html","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":47,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/Response","path":"Anthropic/Error/Response.html","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":56,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"error:Error-instance-method","name":"error","abstract":false,"location":{"filename":"src/error.cr","line_number":60,"url":null},"def":{"name":"error","return_type":"Error","visibility":"Public","body":"@error"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":59,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Error/Response/Error","path":"Anthropic/Error/Response/Error.html","kind":"struct","full_name":"Anthropic::Error::Response::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error/Response","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"message:String-instance-method","name":"message","abstract":false,"location":{"filename":"src/error.cr","line_number":66,"url":null},"def":{"name":"message","return_type":"String","visibility":"Public","body":"@message"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":65,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]}]}]},{"html_id":"anthropic/Anthropic/Event","path":"Anthropic/Event.html","kind":"struct","full_name":"Anthropic::Event","name":"Event","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":99,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/ContentBlockDelta","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta"},{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},{"html_id":"anthropic/Anthropic/ContentBlockStop","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop"},{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},{"html_id":"anthropic/Anthropic/MessageStart","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart"},{"html_id":"anthropic/Anthropic/MessageStop","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop"},{"html_id":"anthropic/Anthropic/MessageStream","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream"},{"html_id":"anthropic/Anthropic/Ping","kind":"struct","full_name":"Anthropic::Ping","name":"Ping"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"new","visibility":"Public","body":"x = allocate\nif x.responds_to?(:finalize)\n ::GC.add_finalizer(x)\nend\nx\n"}}],"instance_methods":[{"html_id":"initialize-instance-method","name":"initialize","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"initialize","visibility":"Public","body":""}}],"macros":[{"html_id":"define(type)-macro","name":"define","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""}],"args_string":"(type)","args_html":"(type)","location":{"filename":"src/event_source.cr","line_number":103,"url":null},"def":{"name":"define","args":[{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":" struct \n{{ type }}\n < ::Anthropic::Event\n include Resource\n\n Event::TYPE_MAP[\n{{ type.stringify.underscore }}\n] = \n{{ type }}\n\n \n \n{{ yield }}\n\n \nend\n \n"}}]},{"html_id":"anthropic/Anthropic/EventMessage","path":"Anthropic/EventMessage.html","kind":"struct","full_name":"Anthropic::EventMessage","name":"EventMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":93,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(data:Array(String),event:String|Nil=nil,id:String|Nil=nil,retry:Int64|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"args_string":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","args_html":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"new","args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(data, event, id, retry)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@data.clone, @event.clone, @id.clone, @retry.clone)"}},{"html_id":"copy_with(data_data=@data,event_event=@event,id_id=@id,retry_retry=@retry)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"args_string":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","args_html":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"copy_with","args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"visibility":"Public","body":"self.class.new(_data, _event, _id, _retry)"}},{"html_id":"data:Array(String)-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"Array(String)","visibility":"Public","body":"@data"}},{"html_id":"event:String|Nil-instance-method","name":"event","abstract":false,"def":{"name":"event","return_type":"String | ::Nil","visibility":"Public","body":"@event"}},{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"retry:Int64|Nil-instance-method","name":"retry","abstract":false,"def":{"name":"retry","return_type":"Int64 | ::Nil","visibility":"Public","body":"@retry"}}]},{"html_id":"anthropic/Anthropic/EventSource","path":"Anthropic/EventSource.html","kind":"class","full_name":"Anthropic::EventSource","name":"EventSource","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":7,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(response:HTTP::Client::Response,last_id:Nil|String=nil)-class-method","name":"new","abstract":false,"args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"args_string":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","args_html":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","location":{"filename":"src/event_source.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(response, last_id)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"last_id:String|Nil-instance-method","name":"last_id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":9,"url":null},"def":{"name":"last_id","return_type":"String | ::Nil","visibility":"Public","body":"@last_id"}},{"html_id":"on_error(&on_error:NamedTuple(status_code:Int32,message:String)->):self-instance-method","name":"on_error","abstract":false,"location":{"filename":"src/event_source.cr","line_number":18,"url":null},"def":{"name":"on_error","yields":1,"block_arity":1,"block_arg":{"name":"on_error","external_name":"on_error","restriction":"(NamedTuple(status_code: Int32, message: String) ->)"},"return_type":"self","visibility":"Public","body":"@on_error = on_error\nself\n"}},{"html_id":"on_message(&on_message:EventMessage,self->):self-instance-method","name":"on_message","abstract":false,"location":{"filename":"src/event_source.cr","line_number":14,"url":null},"def":{"name":"on_message","yields":2,"block_arity":2,"block_arg":{"name":"on_message","external_name":"on_message","restriction":"(EventMessage, self ->)"},"return_type":"self","visibility":"Public","body":"@on_message = on_message\nself\n"}},{"html_id":"response:HTTP::Client::Response-instance-method","name":"response","abstract":false,"location":{"filename":"src/event_source.cr","line_number":8,"url":null},"def":{"name":"response","return_type":"HTTP::Client::Response","visibility":"Public","body":"@response"}},{"html_id":"run:Nil-instance-method","name":"run","abstract":false,"location":{"filename":"src/event_source.cr","line_number":26,"url":null},"def":{"name":"run","return_type":"Nil","visibility":"Public","body":"lines = [] of String\nio = response.body_io\nlast_message = nil\nloop do\n if @abort\n break\n end\n if line = io.gets\n else\n break\n end\n if line.empty? && (!lines.empty?)\n last_message = parse_event_message(lines)\n last_message.id.try do |id|\n @last_id = id\n end\n @on_message.try(&.call(last_message, self))\n lines.clear\n else\n lines << line\n end\nend\nif last_message\n if last_message.id.try(&.empty?) && @abort\n last_message.retry.try do |retry_after|\n sleep(retry_after / 1000)\n end\n end\nend\n"}},{"html_id":"stop:Nil-instance-method","name":"stop","abstract":false,"location":{"filename":"src/event_source.cr","line_number":22,"url":null},"def":{"name":"stop","return_type":"Nil","visibility":"Public","body":"@abort = true"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage","path":"Anthropic/GeneratedMessage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content:Array(MessageContent)-instance-method","name":"content","doc":"This is an array of content blocks, each of which has a `type` that determines\nits shape. Currently, the only `type` in responses is `\"text\"`.\n\nExample:\n\n```json\n[{ \"type\": \"text\", \"text\": \"Hi, I'm Claude.\" }]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the\nresponse `content` will continue directly from that last turn. You can use this\nto constrain the model's output.\n\nFor example, if the input `messages` were:\n\n```json\n[\n {\n \"role\": \"user\",\n \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n },\n { \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{ \"type\": \"text\", \"text\": \"B)\" }]\n```","summary":"
This is an array of content blocks, each of which has a #type that determines its shape.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":43,"url":null},"def":{"name":"content","return_type":"Array(MessageContent)","visibility":"Public","body":"if (value = @content).nil?\n @content = ([] of MessageContent)\nelse\n value\nend"}},{"html_id":"id:String-instance-method","name":"id","doc":"Unique object identifier.\n\nThe format and length of IDs may change over time.","summary":"
Unique object identifier.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":12,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"message_thread:Array(Message)-instance-method","name":"message_thread","doc":"Messages that were passed to the","summary":"
Messages that were passed to the
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":59,"url":null},"def":{"name":"message_thread","return_type":"Array(Message)","visibility":"Public","body":"if (value = @message_thread).nil?\n @message_thread = ([to_message])\nelse\n value\nend"}},{"html_id":"model:String-instance-method","name":"model","doc":"The model that handled the request.","summary":"
The model that handled the request.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":52,"url":null},"def":{"name":"model","return_type":"String","visibility":"Public","body":"@model"}},{"html_id":"role:Message::Role-instance-method","name":"role","doc":"Conversational role of the generated message. This will always be `:assistant`.","summary":"
Conversational role of the generated message.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":49,"url":null},"def":{"name":"role","return_type":"Message::Role","visibility":"Public","body":"@role"}},{"html_id":"stop_reason:StopReason|Nil-instance-method","name":"stop_reason","doc":"The reason that we stopped. This may be one the following values:\n\n- `:end_turn`: the model reached a natural stopping point\n- `:max_tokens`: we exceeded the requested `max_tokens` or the model's maximum\n- `:stop_sequence`: one of your provided custom `stop_sequences` was generated\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is\n`nil` in the `MessageStart` event and non-`nil` otherwise.","summary":"
The reason that we stopped.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":85,"url":null},"def":{"name":"stop_reason","return_type":"StopReason | ::Nil","visibility":"Public","body":"@stop_reason"}},{"html_id":"stop_sequence:String|Nil-instance-method","name":"stop_sequence","doc":"Which custom stop sequence was generated, if any. This value will be a non-\n`nil` string if one of your custom stop sequences was generated.","summary":"
Which custom stop sequence was generated, if any.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":56,"url":null},"def":{"name":"stop_sequence","return_type":"String | ::Nil","visibility":"Public","body":"@stop_sequence"}},{"html_id":"to_message-instance-method","name":"to_message","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":87,"url":null},"def":{"name":"to_message","visibility":"Public","body":"Message.new(role: role, content: content)"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":94,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"content.each do |item|\n io.puts(item)\nend"}},{"html_id":"type:String-instance-method","name":"type","doc":"Object type — for `Message`s, this is always `\"message\"`.","summary":"
Object type — for Messages, this is always "message".
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":46,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}},{"html_id":"usage:Usage-instance-method","name":"usage","doc":"Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the\nunderlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the\nmodel. The model's output then goes through a parsing stage before becoming an\nAPI response. As a result, the token counts in `usage` will not match one-to-one\nwith the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response\nfrom Claude.","summary":"
Billing and rate-limit usage.
","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":75,"url":null},"def":{"name":"usage","return_type":"Usage","visibility":"Public","body":"@usage"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","path":"Anthropic/GeneratedMessage/Content.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":100,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"subclasses":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text"},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":105,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"location = pull.location\ndiscriminator_value = nil\njson = String.build do |io|\n JSON.build(io) do |builder|\n builder.start_object\n pull.read_object do |key|\n if key == \"type\"\n value_kind = pull.kind\n case value_kind\n when .string?\n discriminator_value = pull.string_value\n when .int?\n discriminator_value = pull.int_value\n when .bool?\n discriminator_value = pull.bool_value\n else\n raise(::JSON::SerializableError.new(\"JSON discriminator field 'type' has an invalid value type of #{value_kind.to_s}\", to_s, nil, *location, nil))\n end\n builder.field(key, discriminator_value)\n pull.read_next\n else\n builder.field(key) do\n pull.read_raw(builder)\n end\n end\n end\n builder.end_object\n end\nend\nif discriminator_value.nil?\n raise(::JSON::SerializableError.new(\"Missing JSON discriminator field 'type'\", to_s, nil, *location, nil))\nend\ncase discriminator_value\nwhen \"text\"\n Text.from_json(json)\nwhen \"tool_use\"\n ToolUse.from_json(json)\nelse\n raise(::JSON::SerializableError.new(\"Unknown 'type' discriminator value: #{discriminator_value.inspect}\", to_s, nil, *location, nil))\nend\n"}}],"instance_methods":[{"html_id":"type:Type-instance-method","name":"type","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":103,"url":null},"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content/Type","path":"Anthropic/GeneratedMessage/Content/Type.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::Content::Type","name":"Type","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":110,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Text","name":"Text","value":"0"},{"id":"ToolUse","name":"ToolUse","value":"1"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"instance_methods":[{"html_id":"text?-instance-method","name":"text?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":111,"url":null},"def":{"name":"text?","visibility":"Public","body":"self == Text"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":112,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/StopReason","path":"Anthropic/GeneratedMessage/StopReason.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::StopReason","name":"StopReason","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":159,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"EndTurn","name":"EndTurn","value":"0"},{"id":"MaxTokens","name":"MaxTokens","value":"1"},{"id":"StopSequence","name":"StopSequence","value":"2"},{"id":"ToolUse","name":"ToolUse","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"instance_methods":[{"html_id":"end_turn?-instance-method","name":"end_turn?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":160,"url":null},"def":{"name":"end_turn?","visibility":"Public","body":"self == EndTurn"}},{"html_id":"max_tokens?-instance-method","name":"max_tokens?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":161,"url":null},"def":{"name":"max_tokens?","visibility":"Public","body":"self == MaxTokens"}},{"html_id":"stop_sequence?-instance-method","name":"stop_sequence?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":162,"url":null},"def":{"name":"stop_sequence?","visibility":"Public","body":"self == StopSequence"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":163,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","path":"Anthropic/GeneratedMessage/Text.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":116,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":116,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"text:String|Nil-instance-method","name":"text","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":117,"url":null},"def":{"name":"text","return_type":"String | ::Nil","visibility":"Public","body":"@text"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":119,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"if text = @text\n io.puts(text)\nend"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","path":"Anthropic/GeneratedMessage/ToolUse.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":126,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":126,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":127,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any-instance-method","name":"input","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":130,"url":null},"def":{"name":"input","return_type":"JSON::Any","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":128,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/PossibleSchema","path":"Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html","kind":"module","full_name":"Anthropic::GeneratedMessage::ToolUse::PossibleSchema","name":"PossibleSchema","abstract":false,"locations":[{"filename":"src/generated_message.cr","line_number":132,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"class_methods":[{"html_id":"from_json(json:JSON::PullParser):JSON::Any-class-method","name":"from_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"args_string":"(json : JSON::PullParser) : JSON::Any","args_html":"(json : JSON::PullParser) : JSON::Any","location":{"filename":"src/generated_message.cr","line_number":133,"url":null},"def":{"name":"from_json","args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"return_type":"JSON::Any","visibility":"Public","body":"hash = Hash(String, JSON::Any).new(json)\nresult = hash.fetch(\"properties\") do\n JSON::Any.new(nil)\nend\nif result.as_h?\n result\nelse\n JSON::Any.new(hash)\nend\n"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/Schema","path":"Anthropic/GeneratedMessage/ToolUse/Schema.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse::Schema","name":"Schema","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":145,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":146,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"properties:JSON::Any-instance-method","name":"properties","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":148,"url":null},"def":{"name":"properties","return_type":"JSON::Any","visibility":"Public","body":"@properties"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Usage","path":"Anthropic/GeneratedMessage/Usage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Usage","name":"Usage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":152,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"input_tokens:Int64-instance-method","name":"input_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":155,"url":null},"def":{"name":"input_tokens","return_type":"Int64","visibility":"Public","body":"@input_tokens"}},{"html_id":"output_tokens:Int64-instance-method","name":"output_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":156,"url":null},"def":{"name":"output_tokens","return_type":"Int64","visibility":"Public","body":"@output_tokens"}}]}]},{"html_id":"anthropic/Anthropic/Image","path":"Anthropic/Image.html","kind":"struct","full_name":"Anthropic::Image","name":"Image","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":39,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"base64(media_type:Source::MediaType,data:String)-class-method","name":"base64","abstract":false,"args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(media_type : Source::MediaType, data : String)","args_html":"(media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":43,"url":null},"def":{"name":"base64","args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"new(type: :base64, media_type: media_type, data: Base64.strict_encode(data))"}}],"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":39,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,type:Source::Type,media_type:Source::MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","args_html":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(type: type, media_type: media_type, data: data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"source:Source-instance-method","name":"source","abstract":false,"location":{"filename":"src/message_content.cr","line_number":41,"url":null},"def":{"name":"source","return_type":"Source","visibility":"Public","body":"@source"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":40,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source","path":"Anthropic/Image/Source.html","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":55,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Image","kind":"struct","full_name":"Anthropic::Image","name":"Image"},"constructors":[{"html_id":"new(type:Type,media_type:MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(type : Type, media_type : MediaType, data : String)","args_html":"(type : Type, media_type : MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, media_type, data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@type.clone, @media_type.clone, @data.clone)"}},{"html_id":"copy_with(type_type=@type,media_type_media_type=@media_type,data_data=@data)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"args_string":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","args_html":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"copy_with","args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"visibility":"Public","body":"self.class.new(_type, _media_type, _data)"}},{"html_id":"data:String-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"String","visibility":"Public","body":"@data"}},{"html_id":"media_type:MediaType-instance-method","name":"media_type","abstract":false,"def":{"name":"media_type","return_type":"MediaType","visibility":"Public","body":"@media_type"}},{"html_id":"type:Type-instance-method","name":"type","abstract":false,"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source/MediaType","path":"Anthropic/Image/Source/MediaType.html","kind":"enum","full_name":"Anthropic::Image::Source::MediaType","name":"MediaType","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"JPEG","name":"JPEG","value":"0"},{"id":"PNG","name":"PNG","value":"1"},{"id":"GIF","name":"GIF","value":"2"},{"id":"WEBP","name":"WEBP","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},"instance_methods":[{"html_id":"gif?-instance-method","name":"gif?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":65,"url":null},"def":{"name":"gif?","visibility":"Public","body":"self == GIF"}},{"html_id":"jpeg?-instance-method","name":"jpeg?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":63,"url":null},"def":{"name":"jpeg?","visibility":"Public","body":"self == JPEG"}},{"html_id":"png?-instance-method","name":"png?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":64,"url":null},"def":{"name":"png?","visibility":"Public","body":"self == PNG"}},{"html_id":"to_s-instance-method","name":"to_s","doc":"Returns a `String` representation of this enum member.\nIn the case of regular enums, this is just the name of the member.\nIn the case of flag enums, it's the names joined by vertical bars, or \"None\",\nif the value is zero.\n\nIf an enum's value doesn't match a member's value, the raw value\nis returned as a string.\n\n```\nColor::Red.to_s # => \"Red\"\nIOMode::None.to_s # => \"None\"\n(IOMode::Read | IOMode::Write).to_s # => \"Read | Write\"\n\nColor.new(10).to_s # => \"10\"\n```","summary":"
Returns a String representation of this enum member.