Skip to content

Feature Request: Allow tiktoken to accept a custom HTTP client #462

@GabrielVGS

Description

@GabrielVGS

Summary

I’d like to request a feature that allows passing a custom HTTP client instance to tiktoken, rather than relying on the internal default client.

Motivation

In some environments, it’s necessary to use a custom HTTP client — for example, when the system must connect through a proxy or use a specific SSL certificate for verification. Currently, tiktoken doesn’t expose a way to inject a pre-configured client.

Example use case:

import httpx

custom_client = httpx.Client(verify="/path/to/custom/cert.pem")

tiktoken.encoding_for_model("gpt-4", http_client=custom_client)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions