TestAsyncCompletions Class — anthropic-sdk-python Architecture
Architecture documentation for the TestAsyncCompletions class in test_completions.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 5d2d6298_bff1_a153_810f_431fb4f06edc["TestAsyncCompletions"] 64848efc_cb91_a8cb_d3ef_c23d6a0890a8["Completion"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|extends| 64848efc_cb91_a8cb_d3ef_c23d6a0890a8 7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87["test_completions.py"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|defined in| 7b2ce3d4_e1a4_c107_d39c_452e3c2f8c87 aca0079c_7f3c_9d20_d06e_d63fa5892481["test_method_create_overload_1()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| aca0079c_7f3c_9d20_d06e_d63fa5892481 15bf562d_1f6f_d8fa_3c08_0b8efcd1d533["test_method_create_with_all_params_overload_1()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| 15bf562d_1f6f_d8fa_3c08_0b8efcd1d533 a067bc97_358b_9547_af0f_59cbc0e59ae6["test_raw_response_create_overload_1()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| a067bc97_358b_9547_af0f_59cbc0e59ae6 6325e782_ab55_5470_a06b_e9bb8cee53f4["test_streaming_response_create_overload_1()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| 6325e782_ab55_5470_a06b_e9bb8cee53f4 7fa255d3_6a16_9b8a_8a4a_3b33d6e1392c["test_method_create_overload_2()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| 7fa255d3_6a16_9b8a_8a4a_3b33d6e1392c 12df9019_9b72_4dd7_076b_b6ed4c63aca8["test_method_create_with_all_params_overload_2()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| 12df9019_9b72_4dd7_076b_b6ed4c63aca8 14161fb5_7ee1_f957_ccd4_c3a4ed8ecc65["test_raw_response_create_overload_2()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| 14161fb5_7ee1_f957_ccd4_c3a4ed8ecc65 5e4d19c0_2241_e52e_cadd_3a5cbae0c7fb["test_streaming_response_create_overload_2()"] 5d2d6298_bff1_a153_810f_431fb4f06edc -->|method| 5e4d19c0_2241_e52e_cadd_3a5cbae0c7fb
Relationship Graph
Source Code
tests/api_resources/test_completions.py lines 129–240
class TestAsyncCompletions:
parametrize = pytest.mark.parametrize(
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
)
@parametrize
async def test_method_create_overload_1(self, async_client: AsyncAnthropic) -> None:
completion = await async_client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert_matches_type(Completion, completion, path=["response"])
@parametrize
async def test_method_create_with_all_params_overload_1(self, async_client: AsyncAnthropic) -> None:
completion = await async_client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string"],
stream=False,
temperature=1,
top_k=5,
top_p=0.7,
betas=["string"],
)
assert_matches_type(Completion, completion, path=["response"])
@parametrize
async def test_raw_response_create_overload_1(self, async_client: AsyncAnthropic) -> None:
response = await async_client.completions.with_raw_response.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
completion = response.parse()
assert_matches_type(Completion, completion, path=["response"])
@parametrize
async def test_streaming_response_create_overload_1(self, async_client: AsyncAnthropic) -> None:
async with async_client.completions.with_streaming_response.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
completion = await response.parse()
assert_matches_type(Completion, completion, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_method_create_overload_2(self, async_client: AsyncAnthropic) -> None:
completion_stream = await async_client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
)
await completion_stream.response.aclose()
@parametrize
async def test_method_create_with_all_params_overload_2(self, async_client: AsyncAnthropic) -> None:
completion_stream = await async_client.completions.create(
max_tokens_to_sample=256,
model="claude-opus-4-6",
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
stream=True,
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
stop_sequences=["string"],
temperature=1,
top_k=5,
top_p=0.7,
betas=["string"],
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the TestAsyncCompletions class?
TestAsyncCompletions is a class in the anthropic-sdk-python codebase, defined in tests/api_resources/test_completions.py.
Where is TestAsyncCompletions defined?
TestAsyncCompletions is defined in tests/api_resources/test_completions.py at line 129.
What does TestAsyncCompletions extend?
TestAsyncCompletions extends Completion.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free