I couldn’t find any metric analog to elapsed.total_seconds()
from the legacy API, such as in
rawResponse: LegacyAPIResponse = client.chat.completions.with_raw_response.create(
messages=[...],
functions=myFunctionSpec,
)
responseSeconds: float = rawResponse.elapsed.total_seconds()
New code using Structured Outputs following example from the docs:
completion: ParsedChatCompletion[ResumeSearchQuery] = client.beta.chat.completions.parse(
model='gpt-4o-mini-2024-07-18',
messages=[...],
response_format=MySpec
)
resp: MySpec | None = completion.choices[0].message.parsed