Skip to content

Commit f4806b0

Browse files
authored
Make it clearer how to instrument all OpenAI clients (#1135)
1 parent 1591e92 commit f4806b0

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

docs/integrations/llms/anthropic.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ integration: logfire
33
---
44
# Anthropic
55

6-
**Logfire** supports instrumenting calls to [Anthropic](https://github.com/anthropics/anthropic-sdk-python)
7-
with one extra line of code.
6+
**Logfire** supports instrumenting calls to [Anthropic](https://github.com/anthropics/anthropic-sdk-python) with the [`logfire.instrument_anthropic()`][logfire.Logfire.instrument_anthropic] method, for example:
7+
88

99
```python hl_lines="7"
1010
import anthropic
@@ -13,7 +13,8 @@ import logfire
1313
client = anthropic.Anthropic()
1414

1515
logfire.configure()
16-
logfire.instrument_anthropic(client) # (1)!
16+
logfire.instrument_anthropic() # instrument all Anthropic clients globally
17+
# or logfire.instrument_anthropic(client) to instrument a specific client instance
1718

1819
response = client.messages.create(
1920
max_tokens=1000,
@@ -24,10 +25,6 @@ response = client.messages.create(
2425
print(response.content[0].text)
2526
```
2627

27-
1. If you don't have access to the client instance, you can pass a class (e.g. `logfire.instrument_anthropic(anthropic.Anthropic)`), or just pass no arguments (i.e. `logfire.instrument_anthropic()`) to instrument both the `anthropic.Anthropic` and `anthropic.AsyncAnthropic` classes.
28-
29-
_For more information, see the [`instrument_anthropic()` API reference][logfire.Logfire.instrument_anthropic]._
30-
3128
With that you get:
3229

3330
* a span around the call to Anthropic which records duration and captures any exceptions that might occur

docs/integrations/llms/openai.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ We support instrumenting both the [standard OpenAI SDK](https://github.com/opena
66

77
## OpenAI SDK
88

9-
Logfire supports instrumenting calls to OpenAI with one extra line of code, here's an example of instrumenting
10-
the OpenAI SDK:
9+
**Logfire** supports instrumenting calls to OpenAI with the [`logfire.instrument_openai()`][logfire.Logfire.instrument_openai] method, for example:
1110

1211
```python hl_lines="7"
1312
import openai
@@ -16,7 +15,8 @@ import logfire
1615
client = openai.Client()
1716

1817
logfire.configure()
19-
logfire.instrument_openai(client) # (1)!
18+
logfire.instrument_openai() # instrument all OpenAI clients globally
19+
# or logfire.instrument_openai(client) to instrument a specific client instance
2020

2121
response = client.chat.completions.create(
2222
model='gpt-4',
@@ -28,10 +28,6 @@ response = client.chat.completions.create(
2828
print(response.choices[0].message)
2929
```
3030

31-
1. If you don't have access to the client instance, you can pass a class (e.g. `logfire.instrument_openai(openai.Client)`), or just pass no arguments (i.e. `logfire.instrument_openai()`) to instrument both the `openai.Client` and `openai.AsyncClient` classes.
32-
33-
_For more information, see the [`instrument_openai()` API reference][logfire.Logfire.instrument_openai]._
34-
3531
With that you get:
3632

3733
* a span around the call to OpenAI which records duration and captures any exceptions that might occur

0 commit comments

Comments
 (0)