You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
api_key:"My API Key"# defaults to ENV["OPENAI_API_KEY"]
37
31
)
38
32
39
-
chat_completion =
40
-
openai.chat.completions.create(
41
-
messages: [{
42
-
role:"user",
43
-
content:"Say this is a test"
44
-
}],
45
-
model:"gpt-4o"
46
-
)
33
+
chat_completion = openai.chat.completions.create(
34
+
messages: [{
35
+
role:"user",
36
+
content:"Say this is a test"
37
+
}],
38
+
model:"gpt-4o"
39
+
)
47
40
48
41
puts(chat_completion)
49
42
```
@@ -74,14 +67,13 @@ We provide support for streaming responses using Server Side Events (SSE).
74
67
**coming soon:**`openai.chat.completions.stream` will soon come with Python SDK style higher level streaming responses support.
75
68
76
69
```ruby
77
-
stream =
78
-
openai.chat.completions.stream_raw(
79
-
messages: [{
80
-
role:"user",
81
-
content:"Say this is a test"
82
-
}],
83
-
model:"gpt-4o"
84
-
)
70
+
stream = openai.chat.completions.stream_raw(
71
+
messages: [{
72
+
role:"user",
73
+
content:"Say this is a test"
74
+
}],
75
+
model:"gpt-4o"
76
+
)
85
77
86
78
stream.each do |completion|
87
79
puts(completion)
@@ -107,7 +99,7 @@ puts(file_object.id)
107
99
108
100
### Errors
109
101
110
-
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `OpenAI::Error` will be thrown:
102
+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `OpenAI::Errors::APIError` will be thrown:
111
103
112
104
```ruby
113
105
begin
@@ -219,8 +211,7 @@ Due to limitations with the Sorbet type system, where a method otherwise can tak
219
211
Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience.
@@ -256,8 +247,7 @@ If you want to explicitly send an extra param, you can do so with the `extra_que
256
247
To make requests to undocumented endpoints, you can make requests using `client.request`. Options on the client will be respected (such as retries) when making this request.
0 commit comments