Commit 56fe839
Changed files (1)
README.md
@@ -171,6 +171,22 @@ tools = [
response = client.messages(messages, tools: tools)
```
+## Error Handling
+
+All non-streaming API methods return error information as a hash when requests fail:
+
+```ruby
+response = client.chat(messages, tools)
+
+if response["code"]
+ puts "Error #{response["code"]}: #{response["body"]}"
+else
+ puts response.dig('choices', 0, 'message', 'content')
+end
+```
+
+Streaming methods still raise exceptions on HTTP errors.
+
## API Coverage
### OpenAI