
    /j                    v    S SK Jr  S SKrS SKrS SKrS SKJr  SSKJr  Sr	Sr
SrS	rS
rSS jrSS jrSSS jjrg)    )annotationsN)api   )__version__z&https://agent-gateway.livekit.cloud/v1z.https://agent-gateway.staging.livekit.cloud/v1z
User-AgentzX-LiveKit-Room-IDzX-LiveKit-Job-IDc                     [         R                  R                  S5      n U (       a  U $ [         R                  R                  SS5      nSU;   a  [        $ [        $ )zGet the default inference URL based on the environment.

Priority:
1. LIVEKIT_INFERENCE_URL if set
2. If LIVEKIT_URL contains '.staging.livekit.cloud', use staging gateway
3. Otherwise, use production gateway
LIVEKIT_INFERENCE_URLLIVEKIT_URL z.staging.livekit.cloud)osenvirongetSTAGING_INFERENCE_URLDEFAULT_INFERENCE_URL)inference_urllivekit_urls     P/app/agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/_utils.pyget_default_inference_urlr      sH     JJNN#:;M**..3K;.$$      c                    [         S[         S[        R                  " 5        S30n  SSKJn  U" 5       nUR                  R                  R                  (       a'  UR                  R                  R                  U [        '   UR                  R                  (       a  UR                  R                  U [        '   U $ ! [         a     U $ f = f)zBuild identification headers for inference requests.

Always includes User-Agent with SDK version and Python version.
Includes X-LiveKit-Room-ID and X-LiveKit-Job-ID when running
inside a job context (omitted in console mode or tests).
zLiveKit Agents/z	 (python )r   )get_job_context)HEADER_USER_AGENTr   platformpython_versionjobr   roomsidHEADER_ROOM_IDidHEADER_JOB_IDRuntimeError)headersr   ctxs      r   get_inference_headersr$   &   s     	ok])HD[D[D]C^^_`G	)77<<&)ggll&6&6GN#77::%(WWZZGM" N  Ns   BB; ;
C	C	c                   [         R                  R                  SS9n[         R                  " X5      R	                  S5      R                  U5      R                  [        R                  " US95      R                  5       $ )NT)performagent)seconds)
r   access_tokenInferenceGrantsAccessTokenwith_identitywith_inference_grantswith_ttldatetime	timedeltato_jwt)api_key
api_secretttlgrants       r   create_access_tokenr6   =   s]    ,,T,:E,	w			u	%	($$S1	2	r   )returnstr)r7   zdict[str, str])iX  )r2   
str | Noner3   r9   r4   floatr7   r8   )
__future__r   r/   r   r   livekitr   versionr   r   r   r   r   r    r   r$   r6    r   r   <module>r?      sB    "  	   !@ H   $"!&.r   